The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Phil Budne <phil@ultimate.com>
To: tuhs@tuhs.org
Subject: [TUHS] Re: FD 2
Date: Sun, 29 Jan 2023 19:25:17 -0500	[thread overview]
Message-ID: <202301300025.30U0PHEh022103@ultimate.com> (raw)
In-Reply-To: <emfc4c1646-a458-4e3c-9e39-ca09e9935f74@e41218a5.com>

Ron Natalie wrote:
> Warner Losh 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.
>
> 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.

I think the text Warner quoted applied to only the pre-fork version of
the system, since it's preceeded by:

  "Processes (independently executing entities) existed very early in
  PDP-7 Unix. There were in fact precisely two of them, one for each
  of the two terminals attached to the machine. There was no fork,
  wait, or exec. There was an exit, but its meaning was rather
  different, as will be seen.

and ends with:

  "4) The command did its work, then terminated by calling exit. The
  exit call caused the system to read in a fresh copy of the shell
  over the terminated command, then to jump to its start (and thus in
  effect to go to step 1)."

In the (late) PDP-7 Unix we have sources for, FDs 1 & 2 are
established in init at labels init1 (for the user on the console tty)
and init2 (for the user on the display & display keyboard) after forking
and doing the job of the login executable:

https://github.com/DoctorWkt/pdp7-unix/blob/master/src/cmd/init.s

A remaining mystery about the set of PDP-7 Unix sources we have is
that cat.s (and only cat.s?) writes error messages to FD 8, but I
haven't seen any place that sets FD 8:

https://github.com/DoctorWkt/pdp7-unix/blob/master/scans/cat.s#L43
https://github.com/DoctorWkt/pdp7-unix/blob/master/scans/cat.s#L45
https://github.com/DoctorWkt/pdp7-unix/blob/master/scans/cat.s#L51

Listing scan at:
https://www.tuhs.org/Archive/Distributions/Research/McIlroy_v0/06-5-12.pdf#page=21


  parent reply	other threads:[~2023-01-30  0:25 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 22:44 [TUHS] " ron minnich
2023-01-20 22:54 ` [TUHS] " G. Branden Robinson
2023-01-20 22:56 ` Rob Pike
2023-01-20 23:11   ` Larry McVoy
2023-01-20 23:14     ` Rob Pike
2023-01-20 23:22       ` Larry McVoy
2023-01-20 23:13 ` Douglas McIlroy
2023-01-21  3:37 ` Jon Steinhart
2023-01-21 15:42 ` Clem Cole
2023-01-21 17:34   ` Warner Losh
2023-01-21 17:50     ` Warner Losh
2023-01-21 18:26       ` Clem Cole
2023-01-21 18:37         ` Warner Losh
2023-01-22 11:05           ` Jonathan Gray
2023-01-22 21:23           ` Warner Losh
2023-01-22 22:10             ` ron minnich
2023-01-23  7:30             ` arnold
2023-01-23  8:32               ` James Johnston
2023-01-23  8:58                 ` G. Branden Robinson
2023-01-23 11:49                   ` Brantley Coile
2023-01-23 14:25                     ` Ronald Natalie
2023-01-23 17:43                       ` Brantley Coile
2023-01-23 16:59                 ` Douglas McIlroy
2023-01-24  7:21                   ` arnold
2023-01-29 18:51             ` Warner Losh
2023-01-29 19:20               ` Ron Natalie
2023-01-29 20:25                 ` Warner Losh
2023-01-30  7:50                   ` arnold
2023-01-30  8:09                     ` Rob Pike
2023-01-30 15:02                       ` Larry McVoy
2023-01-30 15:16                         ` Dan Cross
2023-01-30 15:27                           ` Larry McVoy
2023-01-30 15:35                             ` Dan Cross
2023-01-30 15:45                               ` Larry McVoy
2023-01-30 16:09                                 ` Dan Cross
2023-01-30 16:18                                   ` Larry McVoy
2023-01-30 19:03                                     ` Dan Cross
2023-01-30 19:12                                       ` Brantley Coile
2023-01-30 21:24                                       ` Larry McVoy
2023-01-30 22:15                                         ` Rob Pike
2023-01-30 22:50                                           ` ron minnich
2023-01-30 23:05                                           ` [TUHS] Child of plan9? (Re: " Bakul Shah
2023-01-31  3:19                                             ` [TUHS] " Andrew Warkentin
2023-01-30 16:21                                   ` [TUHS] " Steve Nickolas
2023-01-30 16:27                                     ` Larry McVoy
2023-01-30 16:32                                       ` ron minnich
2023-01-30 16:40                                       ` Clem Cole
2023-01-30 19:55                                       ` Lawrence Stewart
2023-01-31 21:27                                     ` Dave Horsfall
2023-01-30 16:48                                   ` Theodore Ts'o
2023-01-30 16:57                                   ` Andy Kosela
2023-01-30 17:04                                     ` Warner Losh
2023-01-30 20:38                                       ` Theodore Ts'o
2023-01-30 21:01                                         ` Warner Losh
2023-01-30 21:10                                         ` Clem Cole
2023-01-30 16:03                           ` Bakul Shah
2023-01-30 16:07                             ` Larry McVoy
2023-01-30 16:13                               ` Bakul Shah
2023-01-30 16:22                                 ` Steve Nickolas
2023-01-30 16:17                               ` Dan Cross
2023-01-30 16:18                             ` Ralph Corderoy
2023-01-30 16:41                               ` [TUHS] job control (Re: " Bakul Shah
2023-01-30 19:07                               ` [TUHS] " Dan Cross
2023-01-30 13:26                     ` John Cowan
2023-01-30 14:30                       ` arnold
2023-01-30  0:25                 ` Phil Budne [this message]
2023-01-30  2:08                   ` Warner Losh
2023-01-21 18:27     ` Clem Cole
2023-01-22 10:56       ` Jaap Akkerhuis via TUHS

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202301300025.30U0PHEh022103@ultimate.com \
    --to=phil@ultimate.com \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).