Hi Linus, Alan,
some applications do need to know where the console (/dev/console)
actually maps to. For processes with a controlling terminal, you may see
it in /proc/$$/stat. However, daemons are supposed to run detached (they
don't want to get killed by ^C) and some processes like init or bootlogd
do still need to be able to find out.
The kernel provides this information -- sort of:
It contains the TIOCTTYGSTRUCT syscall which returns a struct. Of course,
it changes between different kernel archs and revisions, so using it is
an ugly hack. Grab for TIOCTTYGSTRUCT_HACK in the bootlogd.c file of the
sysvinit sources. Shudder!
Having a new ioctl, just returning the device no is a much cleaner solution,
IMHO. So, I created the TIOCGDEV, which Miquel suggests in his sysvinit
sources. It makes querying the actual console device as easy as
int tty; ioctl (0, TIOCGDEV, &tty);
Patches against 2.2.18 and 2.4.0-testX are attached.
Please apply.
-- Kurt Garloff <garloff@suse.de> Eindhoven, NL GPG key: See mail header, key servers Linux kernel development SuSE GmbH, Nuernberg, FRG SCSI, Security
This archive was generated by hypermail 2b29 : Fri Dec 15 2000 - 21:00:34 EST