how can I get filename from file descriptor?

Guy Harris guy at auspex.auspex.com
Fri Aug 25 05:34:09 AEST 1989


>You also need to take into account actions on the fd itself, such as
>unlink(fileno(fd)).

No, you don't; no action on the FD itself will affect any of the links
to the file referred to by that FD, at least in any of the versions of
UNIX I know about.  "unlink" takes a path name, not a file descriptor,
for obvious reasons.

You *do* have to take into account actions on the path, though; if you
open a file and then unlink it, if the name you unlink is the same as
the name remembered by standard I/O (or anybody else), that name will no
longer be valid (the same applies if you rename it from that name). 



More information about the Comp.unix.wizards mailing list