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?
csh
came about because Bill Joy asked him to add - I think - command history and job control to the original borne shell, Bourne told him he was too busy, so then Bill Joy created csh. – the_velour_fog Jun 26 '16 at 03:51exec tcsh -f
then stdin and stdout and not redirected and I don't have any unnecessary open descriptors. I made the mistake of attempting to usetcsh
a few months ago and now I can't get it out of my muscle memory :/ – Greg Nisbet Jun 26 '16 at 04:59