[TUHS] FD 2

Warner Losh imp at bsdimp.com
Sun Jan 22 03:34:37 AEST 2023


On Sat, Jan 21, 2023, 8:45 AM Clem Cole <clemc at ccc.com> wrote:

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

It looks to be a mixed bag in 5th edition. Cc, ac, comm and find all printf
the errors. Diff uses writes to fd 2. I didn't catalog further, but this
kinda looks like a developing convention, not yet fully realized. .

Warner

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/8ec6ae1b/attachment.htm>


More information about the TUHS mailing list