2 edited tags
| link
1
source | link

Why does tcsh consistently have multiple fd's pointing to /dev/tty

This is on Ubuntu 16.04, with bash 4.3.42 and tcsh 6.19

If a open a virtual console not being used by X and run bash, I see stdin, stdout, stderr and a dedicated file descriptor for the tty (apparently).

$ cd /dev/fd
$ ls
0 1 2 255
$ ls -al .
... .
... ..
... 0 -> /dev/tty3
... 1 -> /dev/tty3
... 2 -> /dev/tty3
... 255 -> /dev/tty3

If I'm using tcsh, I see five non-std{in, out, err} file descriptors pointing to the tty and std{in, out, err} are all mapped to /dev/null.

% cd /dev/fd
% ls -al
... .
... ..
... 0 -> /dev/null
... 1 -> /dev/null
... 15 -> /dev/tty3
... 16 -> /dev/tty3
... 17 -> /dev/tty3
... 18 -> /dev/tty3
... 19 -> /dev/tty3
... 2 -> /dev/null

Why would tcsh need so many file descriptors all pointing to the tty and what is the benefit of mapping 0,1, and 2 to /dev/null? Wouldn't that just mean that slightly more bookkeeping is needed when tcsh forks processes so they write to / read from the console?