// console = fopen("con", "wt"); this worked under windows
// console = fopen("/dev/console", "wt"); segmentation fault
console = fopen("/dev/tty0", "wt"); returns zero
Writing in C, using Mint Linux. I want to talk to the console regardless of redirection of stdin & stdout.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With