Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!gem.mps.ohio-state.edu!uakari.primate.wisc.edu!uwm.edu!bionet!ames!pacbell!att!chinet!les From: les@chinet.chi.il.us (Leslie Mikesell) Newsgroups: comp.unix.wizards Subject: Re: how can I get filename from file descriptor? Message-ID: <9767@chinet.chi.il.us> Date: 8 Oct 89 17:58:15 GMT References: <862@cirrusl.UUCP> <11113@smoke.BRL.MIL> <867@cirrusl.UUCP> <1189@necisa.ho.necisa.oz> <947@cirrusl.UUCP> <17109@rpp386.cactus.org> Reply-To: les@chinet.chi.il.us (Leslie Mikesell) Organization: Chinet - Public Access Unix Lines: 29 In article <17109@rpp386.cactus.org> jfh@rpp386.cactus.org (John F. Haugh II) writes: >The only EOF UNIX has this lifetime is zero-length-read. [....] >Actually I think it's the best solution any has ever dreamt up. >The only objects which I am aware of supporting multiple EOFs are >tape devices [ and terminals, but more on that some other day ... ] What about FIFOS, very handy objects available on SysV for the price of typing "/etc/mknod filename p"? If you happen to have machines with RFS, the reader and writer need not even be on the same CPU (which makes other forms of IPC difficult). There are often good reasons for wanting the process on the other end of the fd to think it received an EOF (the same reasons you would type ^D at a terminal). Normally, with a FIFO, the reader receives EOF (i.e. read returns 0) when the last process with the FIFO open for writing closes it. However, this scheme does not always work well, because a) multiple processes writing to the same FIFO may not know about each other, b) the writing process may not know the filename (the original topic of this thread) and may wish to continue using the same channel, and c) it is often desirable to open FIFO's for r/w to provice the correct blocking behaviour, in which case the reader never sees a writer's close. >The zero-length-read paradigm has a very intuitve meaning. It >means there is nothing left to read ... No, it means there is nothing currently to read, even with files. Otherwise there would be no such thing as "tail -f". Les Mikesell