On Sun, Jan 29, 2023, 12:21 PM Ron Natalie <ron@ronnatalie.com> wrote:

 
"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.

This was in reference to the pdp-7 unix implementation. I didn't check the pdp7 version though. So what you said is true about the later versions for sure, starting with v5.

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.


Yes. I quite enjoyed that.

My surprise was Dennis' paper didn't mention the innovation since it was otherwise quote detailed.

Warner