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 20902 invoked from network); 29 Jan 2023 18:53:26 -0000 Received: from minnie.tuhs.org (50.116.15.146) by inbox.vuxu.org with ESMTPUTF8; 29 Jan 2023 18:53:26 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 146B5424AA; Mon, 30 Jan 2023 04:53:02 +1000 (AEST) Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by minnie.tuhs.org (Postfix) with ESMTPS id 3B985424A9 for ; Mon, 30 Jan 2023 04:52:50 +1000 (AEST) Received: by mail-ej1-f48.google.com with SMTP id p26so15021685ejx.13 for ; Sun, 29 Jan 2023 10:52:50 -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=WVAIa5Yu+ePFoK2LxKMcyHvz6LPecm8unGSfJtsuf0E=; b=PLNIF5YqTPyx9HU2LK5al29RnIa/hIR884uAvvz0aU4PGMDYjGfwpspMV8AYJshcWW 9A/K7sJA00/Isr8USayRUk0CDrm8i6SESrU0QB2G4qOm7zvaTLyBkWIDqQbdsieZUmT/ 4ApFT0QY2ThXVLBbnGZGKoco+asQAChjPmSkYFHvZkdu2+nvJYPRbL651N5Tbk4A+tpO 9IfqPR25jWKaL0AOfZ+hu3Zutlhuh6F13rsar15KW4g+k2YsueFHs0XglnQW+Uv0FeJ0 Y7q8BkVKwEXm19H1PRQtPsUaNhx9IJ6X2OnZ3eG5K88K4+zICSLDS0ridqi7FBMmsrkB PQyg== 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=WVAIa5Yu+ePFoK2LxKMcyHvz6LPecm8unGSfJtsuf0E=; b=ngF8RVh45qsQ9NLQOA9Krb7JRg1JX6tonmqZvr8yWcLJZFO14O5mr8OrSeakGEqiI8 nDtnmY2SjjUdPIUBUaIRxrZJx2F0e2lvUjj7iPxu1c8/HJ8RDrdMa4H5ypbWIsa/AMJi 3Qje7adThbw6/DC2Wps/7VuK5eOdNygEkwY5QswJ6sczcLKU6Agkstyh6oUE4Xo3d0x4 B46H4BDT+L0zDCCIdpFA20eHHLcGvNXfCXmYOdCMqnHffxZ8TF9lNrj3Kyc7u0yBSd5V EM6LoYXFsmPmxFjYcvL5Ji57QnD3zSXqe9MNO+PGRxB4qO32aJ5HK9/YOoH9lcWplO/B G8Kw== X-Gm-Message-State: AO0yUKXk2UJRp3KQnK3JvQu7N8EkFbGeqbqqLHIQVTtXrBwSSCPji7l2 7igjXbYt2mgi5oMyT3OTzWZa7JwFu7DMjH/vZaAXS0PTsakf9XCo X-Google-Smtp-Source: AK7set+8kOW0r9Nt6FnRd68hVIVayDcnpBLtwG9jLHEoqPdP4Jem9hmJHfdD/USkJaqHgNWZ93bzPfM5z5/SIg+F4nU= X-Received: by 2002:a17:906:4ac2:b0:888:c14e:70b6 with SMTP id u2-20020a1709064ac200b00888c14e70b6mr197419ejt.306.1675018308603; Sun, 29 Jan 2023 10:51:48 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Warner Losh Date: Sun, 29 Jan 2023 11:51:43 -0700 Message-ID: To: Clem Cole Content-Type: multipart/alternative; boundary="00000000000046e14605f36b979a" Message-ID-Hash: Y5KBWHZ4GHTL4DFOMJRJEW6NBVLXTVEE X-Message-ID-Hash: Y5KBWHZ4GHTL4DFOMJRJEW6NBVLXTVEE 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: --00000000000046e14605f36b979a Content-Type: text/plain; charset="UTF-8" On Sun, Jan 22, 2023 at 2:23 PM Warner Losh wrote: > > > On Sat, Jan 21, 2023 at 11:37 AM Warner Losh wrote: > >> >> Yea. Like many things, there was a transition... the most important bit >> is the shell. And that was more tricky to read through with the phone at >> breakfast... >> > > OK. I've dug a bit further and Clem and I have chatted... Here's the > summary. > > We don't have V4's shell, alas, since all we have from that time period is > the C kernel a few months before the 4th edition release. V5 /bin/sh closes > fd2 and then dups fd1 to fd2. This creates fd2 as something special. V6 > closes all FD's larger than 1 (2-15) and then does the dup(1) which it > makes sure returns 2 or it closes the file. While there were features in V6 > to allow use of fd2/stderr, few programs used then. > > And neither crypt nor passwd reads from fd2. crypt reads from fd0, while > passwd doesn't read. It just replaces the hashed password with the new > password. I've also looked at pr because > > >I do remember that pr -p actually read from FD 2. It probably still does. > > and that's not true in V7 at least... pr didn't have a 'p' arg :). Maybe > later programs started to do these things, but most of what went on with V7 > was a transition to most error messages on stderr, which typically went to > stdout in V6. > > So, people remembering it coming in with V7 are right, in the sense it was > the first release to do it consistently. And the people remembering V4 or > V5 are also right, in a different sense because the shell was ensuring fd2 > was a copy of fd1 there, which a couple of programs (diff) used for errors. > And I believe that the impetus for the V7 changes was phototypesetting > 'file not found' too often... But that last bit is mostly because I want > to believe. > One last historical footnote. In researching a forthcoming article for the 30th anniversary of FreeBSD, I noticed the following: https://www.bell-labs.com/usr/dmr/www/hist.pdf contains Dennis Ritchie's history of the early days of Unix. It was first published in 1979 (so right around the time V7 was being finalized), and revised/reprinted in the famous AT&T Bell Laboratories Technical Journal 63 No. 6 Part 2, October 1984 issue. He talks about FD 0 and FD 1 being special in the pdp-7 implementation on page 4: "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). ..." No mention is made of when fd 2 became standard error in this paper, which does mention a lot of other unix milestones (hierarchical notation for directories, fork/exec changes, pipes, etc), but not this one. > Warner > --00000000000046e14605f36b979a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sun, Jan 22, 2023 at 2:23 PM Warne= r Losh <imp@bsdimp.com> wrote:<= br>


On Sat, Jan 21, 2023 at 11:37 AM Warner Losh <imp@bsdimp.com> wrot= e:

Yea. Like many things, there was a transition...= the most important bit is the shell. And that was more tricky to read thro= ugh with the phone at breakfast...

<= div>OK. I've dug a bit further and Clem and I have chatted...=C2=A0 Her= e's the summary.

We don't have V4's sh= ell, alas, since all we have from that time period is the C kernel a few mo= nths before the 4th edition release. V5 /bin/sh closes fd2 and then dups fd= 1 to fd2. This creates fd2 as something special. V6 closes all FD's lar= ger than 1 (2-15) and then does the dup(1) which it makes sure returns 2 or= it closes the file. While there were features in V6 to allow use of fd2/st= derr, few programs used then.

And neither crypt no= r passwd reads from fd2. crypt reads from fd0, while passwd doesn't rea= d. It just replaces the hashed password with the new password. I've als= o looked at pr because

>I do remember that pr -= p actually read from FD 2. It probably still does.

and that's not true in V7 at least... pr didn't h= ave a 'p' arg :). Maybe later programs started to do these things, = but most of what went on with V7 was a transition to most error messages on= stderr, which typically went to stdout in V6.

So, people remembering it coming i= n with V7 are right,=C2=A0in the sense it was the first release to=C2=A0do = it consistently. And the people remembering V4 or V5 are also right, in a d= ifferent sense because the shell was ensuring fd2 was a copy of fd1 there, = which a couple of programs (diff) used for errors. And I believe that the i= mpetus for the V7 changes was phototypesetting 'file not found' too= often...=C2=A0 But that last bit is mostly because I want to believe.

One last historical footnote. In re= searching a forthcoming article for the 30th anniversary of FreeBSD, I noti= ced the following:

https://www.bell-labs.com/usr/dmr/www/hist.= pdf contains Dennis Ritchie's history of the early days of Unix. It= was first published in 1979 (so right around the time V7 was being finaliz= ed), and revised/reprinted in the famous AT&T Bell Laboratories Technic= al Journal 63 No. 6 Part 2, October 1984 issue. He talks about FD 0 and FD = 1 being special in the pdp-7 implementation on page 4:

=
"The main loop of the shell went as follows:
1) The she= ll closed all its open files, then opened the terminal special file for sta= ndard input and output (file descriptors 0 and 1).
..."

No mention is made of when fd 2 became standard error = in this paper, which does mention a lot of other unix milestones (hierarchi= cal notation for directories, fork/exec changes, pipes, etc), but not this = one.
=C2=A0
Warner
--00000000000046e14605f36b979a--