Subject: On /dev/console, /dev/constty and the TIOCCONS ioctl
To: None <tech-kern@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 10/03/2003 21:05:06
I've committed changes today that add a /dev/constty device, and changed
/etc/ttys so that getty (and hence any console login session) use it
instead of /etc/console. init also uses it for single user mode.

Provided that MAKEDEV is run after /etc/ttys is updated this should
all be transparant.  init will fall back on /dev/console, and old kernels
will treat /dev/constty the same way as they treat /dev/console.

At least one other Unix system uses /dev/constty.

The only difference between /dev/console and /dev/constty is that output
to the latter is not intercepted by the TIOCCONS ioctl.

I made the change because I want to capture kernel messages generated
while sysinst is running in order to stop them 'messing up' the screen.

It also makes it possible to log in on the 'console' while xconsole
(or similar) is running - a problem someone else mentioned yesterday.

Without the change it is impossible for a program running from the console
to output data to the console if TIOCCONS has been used to transfer kernel
messages to a pty.

I did look at trying to detects writes to a processes controlling terminal,
however its tty structure is that for the underlying device (eg ttyE0)
so that just doesn't work.  You would need to have the vnode address
available in the device driver write routine......

The code changes are trivial (adding minor(dev) == 0 to a few code paths)
and updating 10^9 copies of MAKEDEV and /etc/ttys.

One loose end is that init gives anything it runs a controlling terminal
of /dev/console.  I'm not 100% clear this is correct.  If any daemons
are started that fail to lose their ctty, then ttyE0 (on i386) will be
left with an attached session. 

Anyone know where /dev/console is documanted?

	David

-- 
David Laight: david@l8s.co.uk