SURVEY RESULTS: Should fd 3 be /dev/tty?

Mike Haertel mike at thor.acc.stolaf.edu
Sun May 7 03:36:37 AEST 1989


>In article <8123 at phoenix.Princeton.EDU> bernsten at phoenix.Princeton.EDU (Dan Bernstein) writes:
>|(3) v8/v9 already has fd 3 as /dev/tty:   Why? AT&T, if you want
>|to make this change, go all the way and accompany stdin, stdout,
>|and stderr with cmdin. Don't make a non-redirectable file descriptor
>|for what's already in the name space.

v9 has a /dev/tty which is just a link to /dev/fd/3.

When v9 programs need to get at the terminal, I bet they just open
/dev/tty like on any other version of Unix.

One good reason to implement /dev/tty this way is that /dev/tty is
a pretty weird device driver with an incestuous relationship to
other data structures in the kernel.  /dev/fd/ has a similar problem.
By implementing /dev/tty as a link to /dev/fd/3 the v9 people
were able to reduce the count of ugly incestuous drivers to 1.

Another advantage is that one can redirect descriptor 3 to fool
programs that stupidly insist on talking to /dev/tty.  With streams
you can even give them a working tty ioctl interface . . .
-- 
Mike Haertel <mike at stolaf.edu>
main() ??< printf("hello, world??/n"); ??>



More information about the Comp.unix.wizards mailing list