site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Hi Greg, On Tue, Mar 1, 2011 at 8:47 PM, Greg Parker <gparker@apple.com> wrote:
No. The problem is that there's no "close all but these" file action for posix_spawn(). There's no safe way for posix_spawn() to create a child process with all descriptors closed except a known set like stdin/out/err. You cannot safely use posix_spawn_file_actions_addclose() for every open descriptor in the parent, because other threads in the parent may be concurrently opening and closing those descriptors between the time you set up the file actions and the time you call posix_spawn().
But what if you added a close action for all possible file descriptors except for stdin, stdout & stderr? i.e. looped over all 1024 (or however many) file descriptors except for those three? And how exactly would you close file descriptors between the fork and exec? How do you know what file descriptors to close? -- Chris _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com