Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!att!cbnewsl!ams From: ams@cbnewsl.ATT.COM (andrew.m.shaw) Newsgroups: comp.unix.wizards Subject: Re: how can I get filename from file descriptor? Message-ID: <1657@cbnewsl.ATT.COM> Date: 28 Aug 89 18:32:42 GMT References: <10850@smoke.BRL.MIL> Reply-To: ams@cbnewsl.ATT.COM (andrew.m.shaw,580,) Organization: AT&T Bell Laboratories Lines: 28 In article <10850@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In article <1639@cbnewsl.ATT.COM> ams@cbnewsl.ATT.COM (andrew.m.shaw,580,) writes: >> Please tell me how to "send EOF" to a pipe reader without closing >> the FIFO... > >If your pipe implementation is any good (most are not), simply write 0 >bytes to it. 'Twon't work in System V, and my POSIX says (emphasis mine) (6.1.4.2): (1) If no process has the pipe open for writing, read() shall return 0 to indicate end-of-file. (2) ... (3) If some process has the pipe open for writing and O_NONBLOCK is clear, read() shall block until *some* data is written or the pipe is closed by all processes that opened the pipe for writing. Now, is a null write writing *some* data? From POSIX 6.4.2.2: If nbyte is zero, the write function shall return zero *and have no other results* if the file is a regular file; otherwise the results are implementation dependent. ... Write requests to a pipe (or FIFO) shall be handled the same as a regular file with the following exceptions: [4 exceptions listed, none germane to topic at hand]. So my feeling is that any implementation that supports "write 0 bytes to satisfy the read" is non-POSIX-compliant, and therefore code that relies on it is non-portable, &c, &c. Andrew Shaw