>> This makes me wonder if perhaps login sessions should have their >> stdin/stdout/stderr set up on /dev/tty instead of the actual ctty >> device. But if that's done, will the `real' ctty device even be >> open? [...]
It actually occurs to me that this is a potential problem even today: what happens if all the processes in a session close the descriptors they have on the ctty, and there are no others lying around in other processes, and then one of those processes tries to access /dev/tty? It would be an unusual session, true, but there's nothing preventing it from happening as far as I can see. Would the underlying tty driver explode upon getting I/O calls when it isn't open, or what? I think I'll build a test program that does this: does setsid(), opens a tty (which would have to not be open by anything else, for the test to be useful), does TIOCSCTTY, opens /dev/tty, closes all its descriptors on the real tty, then accesses its /dev/tty descriptor.... /~\ The ASCII Mouse \ / Ribbon Campaign X Against HTML mo...@rodents-montreal.org / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B