09 July 2012

Redirecting console output to a pseudotty

Using the TIOCCONS ioctl one can redirect console output to a pseudotty.
This is what xterm -C and xconsole do.

get latest pseudocons.c
# gcc -Wall -o pseudocons pseudocons.c -lutil
# ./pseudocons
[pseudocons]got master
[pseudocons]got slave console
[cons]Hoera..
[cons][pseudocons]Got Ctrl+C; Exiting...

execute the below command from another window to get the above output
# echo Hoera.. > /dev/console

Reference:
http://www.win.tue.nl/~aeb/linux/lk/lk-2.html

No comments:

Post a Comment