Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!att!chinet!les From: les@chinet.chi.il.us (Leslie Mikesell) Newsgroups: comp.unix.wizards Subject: Re: shell file descriptor programming (was: Unlinked temp files) Message-ID: <8473@chinet.chi.il.us> Date: 17 May 89 17:13:29 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> Reply-To: les@chinet.chi.il.us (Leslie Mikesell) Organization: Chinet - Public Access Unix Lines: 40 In article <11529@ulysses.homer.nj.att.com> ekrell@hector.UUCP (Eduardo Krell) writes: >>With /bin/sh, it's easy enough to include in /etc/profile >>(or wherever) a set of lines that initialize these files to a default (an >>audit trail, for example), and then just assume that the files are always >>available. ^^^^^^ >That's the problem. What makes you think this is a safe assumption? 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? >There are already too many ways of breaking this. Say you want to >run this program you have from within an editor or a shell script >or some other program. Then you should expect an error just like you would get with a program that wants to open a file that is not accessable. >What makes you think the file descriptors you need (>2) are still >open? Many programs start with closing all file descriptors >2. >The only standard file descriptors that all programs expect to be >opened are 0, 1, and 2. Is this documented somewhere? I think the only program that has any business closing open files if it expects to start general-purpose children is "getty", and it shouldn't have to. >You aren't allowed to modify the list because there is no notation >for it. Someone suggested to overload the export builtin to allow >to specify which file descriptors would be "exported" to exec'ed >processes (default being 0, 1, and 2), but the current POSIX draft >doesn't support that. If I: exec 3bar under what conditions should I not expect to be able to access these files? Les Mikesell