Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!rutgers!apple!ames!pasteur!ucbvax!ulysses!hector!ekrell From: ekrell@hector.UUCP (Eduardo Krell) Newsgroups: comp.unix.wizards Subject: Re: shell file descriptor programming (was: Unlinked temp files) Message-ID: <11540@ulysses.homer.nj.att.com> Date: 18 May 89 02:22:27 GMT References: <871@marvin.Solbourne.COM> <1015@philmds.UUCP> <296@tree.UUCP> <4542@psuvax1.cs.psu.edu> <134@minya.UUCP> <11529@ulysses.homer.nj.att.com> <8473@chinet.chi.il.us> Sender: netnews@ulysses.homer.nj.att.com Reply-To: ekrell@hector.UUCP (Eduardo Krell) Organization: AT&T Bell Laboratories Lines: 37 In article <8473@chinet.chi.il.us> les@chinet.chi.il.us (Leslie Mikesell) writes: >How about the man page for exec(2) where it says that file descriptors >open in the calling process remain open in the new process? That man page says nothing about individual programs. >>The only standard file descriptors that all programs expect to be >>opened are 0, 1, and 2. > >Is this documented somewhere? It's tradition. Why do you think stdio only defines stdin, stdout and stderr? >If I: >exec 3bar >under what conditions should I not expect to be able to access these >files? Those files are opened to the shell. The shell has every right to exec a process with the close-on-exec flags on all file descriptors other than 0, 1, 2 and any file descriptors indicated in the command line (as in "program 3bar"). The real problem is that the close-on-exec flag was a late arrival into Unix and so the default exec() behavior remained not to use the close-on-exec flag (because there was no such a flag when it all started). I think this is a mistake. File descriptors are part of the environment of a process, and like environment variables, shouldn't be exported by the shell unless it's done explicitly (by something like the overloading of the "export" builtin I described). Eduardo Krell AT&T Bell Laboratories, Murray Hill, NJ UUCP: {att,decvax,ucbvax}!ulysses!ekrell Internet: ekrell@ulysses.att.com