how can I get filename from file descriptor?

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Oct 7 10:40:59 AEST 1989


In article <947 at cirrusl.UUCP> dhesi%cirrusl at oliveb.ATC.olivetti.com (Rahul Dhesi) writes:
>In article <1189 at necisa.ho.necisa.oz> boyd at necisa.ho.necisa.oz (Boyd Roberts)
>writes:
>>There is no EOF in UNIX; ...
>>...A suitable stream line discipline would solve 
>>whatever your problem is.
>There *is* an EOF in UNIX.  Enough UNIX documentation says it that I
>believe it.  Case closed.

UNIX beginner's documentation talks in terms of EOF to keep the notion
simpler for the novice.  However, Boyd is right; there is no EOF in UNIX.
There is a 0 return from read(), which is often INTERPRETED as meaning
EOF.

>The zero-length read/write strategy, besides not working for pipes,
>also doesn't work with buffered streams.  It's a pretty poor solution
>at this time.

0 return from read() always works.  The problem is that many common
implementations do not creat a 0-length packet when you write() 0 bytes.
Thus it is IMPOSSIBLE to "read EOF" more than once from a pipe on such a
system.  There have been implementations that support writing 0-length
packets.  That's effectively what most UNIX terminal drivers do when
the "EOF" character (typically ctrl-D) is entered immediately after a
preceding delimiter ("EOF" or "newline").

The fact is, there are some pretty poor implementations of UNIX in
widespread use..



More information about the Comp.unix.wizards mailing list