From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HTML_MESSAGE,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8765 invoked from network); 30 Jan 2023 02:09:57 -0000 Received: from minnie.tuhs.org (50.116.15.146) by inbox.vuxu.org with ESMTPUTF8; 30 Jan 2023 02:09:57 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 2D927424BA; Mon, 30 Jan 2023 12:09:51 +1000 (AEST) Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by minnie.tuhs.org (Postfix) with ESMTPS id 69B8A4241D for ; Mon, 30 Jan 2023 12:09:45 +1000 (AEST) Received: by mail-ej1-f41.google.com with SMTP id p26so16606638ejx.13 for ; Sun, 29 Jan 2023 18:09:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=idMPLkwLMFAkCIfA2cBheo4RQNqFCh1tBMYJZXZekk8=; b=zut9VINWMppMMBAPu9dUil3huEHij2Lnnktmzr0MxAP802X8GruPRPT7U+uqQgH03Q SxMiaV3+mEHa1HpOwOYvGok6So8taDLw6SwSaqkEG+GFO/+IAqASo7QbgP5EiNZO2rMy kBb6tKJHtzTsP4SUEaPei421wKHfyZb6ldi+9ePlLdYJzPs0801n0SNJdRdJoOmTEpM5 qeVCUaLPZkwFyrL+xfODFvEI+K4sYiIz8YTCr924MXQ4vsA0Ee+A87dy78j7C0r/kY8F UYw/+aGG24n8ydw3gXy6Qpgy5Tje9/+ZkvcIqKQPV3BS/kt9/yZ5A+SCVTD5HB6RNs+K HOyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=idMPLkwLMFAkCIfA2cBheo4RQNqFCh1tBMYJZXZekk8=; b=obQVGOvN93aX0+S9CHNgxY1uulurgcPGSuL5Vvf+3V0hHTLZPHrNnDaCcnEPQz/COl cgKbQK4bWDAGcDtROCOoX8QUtdQ6Y9FT+Fo6fI/58AbE0Q15srdkmRlSxH8zEWOe4FS1 eFyg5jbWMh1S+Zh1Bq+mRSDgJ+BiEH3SYHtV2dm0z55RIzO9O9t9G8UrCZ1eSDi7yDTe 0vKBlpd8GkrUzAgj9wXmq6rR4CbHVa1yacSZCiWmrMLWvcJlFbL/cI2ddzPWPMbhP/GZ E6IQdq6dynjSGDA3/mMrSu4ITEFXZb9PiMrraxEe6UzGaWhne2cbLTXJI8TLYDVLvsvL to8A== X-Gm-Message-State: AFqh2kr4xoS4U4ILq4zZERqDGLybzpICz1RfoyNepZDYcZ195vPAIemr utkp3dRon3vPvkq5nS7AQ18Uy9hqn40eL4neND7TpUigqyatHA== X-Google-Smtp-Source: AMrXdXvcQK2AHo0ghXEBhnO3iGC3lzLo87ZE0vKUE0fM+v00KA4+LD95IAELgPrkO90srQA1FxJNzFuOJ6Vp39aDQx4= X-Received: by 2002:a17:906:2752:b0:86f:f0ce:a227 with SMTP id a18-20020a170906275200b0086ff0cea227mr7474414ejd.160.1675044523837; Sun, 29 Jan 2023 18:08:43 -0800 (PST) MIME-Version: 1.0 References: <202301300025.30U0PHEh022103@ultimate.com> In-Reply-To: <202301300025.30U0PHEh022103@ultimate.com> From: Warner Losh Date: Sun, 29 Jan 2023 19:08:32 -0700 Message-ID: To: Phil Budne Content-Type: multipart/alternative; boundary="000000000000d3a5e605f371b16f" Message-ID-Hash: 5QHKXA77WRZETUF5WOUQIPZW7QTSH2WU X-Message-ID-Hash: 5QHKXA77WRZETUF5WOUQIPZW7QTSH2WU X-MailFrom: wlosh@bsdimp.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-tuhs.tuhs.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: The Eunuchs Hysterical Society X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [TUHS] Re: FD 2 List-Id: The Unix Heritage Society mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --000000000000d3a5e605f371b16f Content-Type: text/plain; charset="UTF-8" On Sun, Jan 29, 2023, 5:25 PM Phil Budne wrote: > 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 It looks like 0 & 1 to me. Am I missing something? Warner > > 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 > > --000000000000d3a5e605f371b16f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sun, Jan 29, 2023, 5:25 PM Phil Budne <phil@ultimate.com> wrote:
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 <= br> > >special file for standard input and output (file descriptors 0 and= 1).
> >
> Unfortunately, the source code says otherwise.=C2=A0 =C2=A0None of she= lls V6, PWB,
> V7 do anything like is mentioned above.=C2=A0 =C2=A0They 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.=C2=A0 =C2=A0= 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).=C2=A0 =C2=A0In V7, init added a secon= d 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:

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

and ends with:

=C2=A0 "4) The command did its work, then terminated by calling exit. = The
=C2=A0 exit call caused the system to read in a fresh copy of the shell
=C2=A0 over the terminated command, then to jump to its start (and thus in<= br> =C2=A0 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 forkin= g
and doing the job of the login executable:

https://github.com/Docto= rWkt/pdp7-unix/blob/master/src/cmd/init.s


It loo= ks like 0 & 1 to me. Am I missing something?
Warner
--000000000000d3a5e605f371b16f--