I have written a deamon in C working on Linux, and now I need to be able to send short messages to Linux console like the commad "wall" does, or how init does when it reboots the system.
How to do that from inside my program ?
best regards
Marek
I have written a deamon in C working on Linux, and now I need to be able to send short messages to Linux console like the commad "wall" does, or how init does when it reboots the system.
How to do that from inside my program ?
best regards
Marek
The current console linux device is /dev/console
, but you need to be root to write to this file.
See the man page for console for more info, but here is an extract:
Common ways to start a process on a console are:
To send messages to multiple terminals/consoles use the
ttymsg()
on various tty nodes.
For a good example on how to use this is your C program, checkout the source of the walk
command. We can see precisely how it prepares a message buffer and sends it as a broadcast to various terminals of all the currently logged-in users.
For sending ocasional short messages, the best (most portable, simplest) way to do it would be just to run wall(1).
I would like to avoid executing other binaries from my program. Solution with ttymsg and code from wall program works for me well.
Thanks for help Marek