[TUHS] FD 2
Ron Natalie
ron at ronnatalie.com
Mon Jan 30 05:20:43 AEST 2023
>"The main loop of the shell went as follows:
>1) The shell closed all its open files, then opened the terminal
>special file for standard input and output (file descriptors 0 and 1).
>
Unfortunately, the source code says otherwise. None of shells V6, PWB,
V7 do anything like is mentioned above. They assume 0 and 1 (and 2)
are already open.
The only fd redirection they do is when you do pipes or redirection on
the command line.
Where this is done is, as I posted earlier, in /etc/init. Init opens
the tty device and dups it to 1 and then invokes either the shell (if
we're in single user mode) or getty for interactive mode.
This was done in V6 and PWB (1). In V7, init added a second dup for
file descriptor 2.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20230129/b8600b80/attachment.htm>
More information about the TUHS
mailing list