[TUHS] FD 2

Clem Cole clemc at ccc.com
Sun Jan 22 01:42:59 AEST 2023


Certainly fd 2 as a error output appears with Lesk's portable C library,
which was included in V6 - see the last para on page 1 of his document:

"Initially you are given three file descriptors by the system: 0, 1, and 2.
File 0 is the standard input; it is normally the teletype in time-sharing
or input data cards in batch. File 1 is the standard output; it is nor-
mally the teletype in time-sharing or the line printer in batch. File 2 is
the error file; it is an output file, nor- mally the same as file 1, except
that when file 1 is diverted via a command line ’>’ operator, file 2
remains attached to the original destination, usually the terminal. It is
used for error message output. These popular UNIX conventions are
considered part of the C library specification. By closing 0 or 1, the
default input or output may be re-directed; this can also be done on the
command line by >file for output or <file for input."

This document pre-dates ditroff.   The idea/names of stdin/out/err (as
opposed to fd 0, 1, 2) does not come about until Dennis does "typesetter C"
which is described in K&R.

That said, my memory is fd 2 as ana error path was there in Fourth or Fifth
Edition, before Lesk did this library -- i.e. it was a convention that
Dennis/Ken et al were all using -- when it is realized that printing errors
on in the same output flow as the standard (normal) output was problematic
in a pipe stream.
ᐧ

On Fri, Jan 20, 2023 at 5:46 PM ron minnich <rminnich at gmail.com> wrote:

> I am trying to remember when fd 2 (aka stderr) became a thing. I have a
> vague memory that it was post-v6 but that may be way off.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20230121/5d08ee1f/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iolib.pdf
Type: application/pdf
Size: 46203 bytes
Desc: not available
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20230121/5d08ee1f/attachment-0001.pdf>


More information about the TUHS mailing list