无法打开/ dev /控制台 [英] Cannot open /dev/console

查看:224
本文介绍了无法打开/ dev /控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//  console     = fopen("con",  "wt");       this worked under windows
//  console     = fopen("/dev/console",  "wt");     segmentation fault
    console     = fopen("/dev/tty0",  "wt");     returns zero

C语言编写,使用薄荷Linux操作系统。我想谈的控制台,无论标准输入和放大器的重定向;标准输出。

Writing in C, using Mint Linux. I want to talk to the console regardless of redirection of stdin & stdout.

推荐答案

的/ dev /控制台设备并不一定提供给您。对于Linux,如果你碰巧看到当前虚拟终端该设备只能显示出任何结果。另外(包括Linux),对于大多数系统的/ dev /控制台需要提升的权限来打开它,例如,你的应用程序作为。其原因是因为有些系统消息被写入到系统控制台。

The /dev/console device is not necessarily available to you. For Linux that device would only show any result if you happen to look at the current virtual terminal. Also (including Linux), for most systems /dev/console requires elevated permissions to open it, e.g., your application is running as root. The reason for that is because some system messages are written to the system console.

有关进一步的讨论,这里有几个链接:

For further discussion, here are a few links:

  • Linux: Difference between /dev/console , /dev/tty and /dev/tty0
  • 7. Terminal Special Files such as /dev/tty from Text-Terminal HOW-TO
  • Understanding /dev from Linux Journal

这篇关于无法打开/ dev /控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆