Author nadeem.vawda
Recipients gregory.p.smith, jyasskin, nadeem.vawda, pitrou, rosslagerwall
Date 2011-01-05.00:54:32
SpamBayes Score 6.67246e-05
Marked as misclassified No
Message-id <1294188878.62.0.873682623406.issue8052@psf.upfronthosting.co.za>
In-reply-to
Content
According to POSIX [1], if a multi-threaded program calls fork(), the child process may only use async-signal-safe system calls between fork() and exec*(). readdir() is not required to be async-safe [2], so reading /proc/self/fds in the child process is undefined behaviour. This is a pity, since it would IMO be a much cleaner solution than the current code.

Of course, procfs isn't standard in any case; would it be necessary to have a fallback for systems without it? Or do all *nix systems that we care about provide it? In the former case, I suppose it might be possible to use the procfs on systems where readdir() is known to be safe, and use the fallback where it isn't. But such special cases would complicate the code rather than simplifying it...

[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/fork.html
[2] http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html
History
Date User Action Args
2011-01-05 00:54:38nadeem.vawdasetrecipients: + nadeem.vawda, gregory.p.smith, pitrou, jyasskin, rosslagerwall
2011-01-05 00:54:38nadeem.vawdasetmessageid: <1294188878.62.0.873682623406.issue8052@psf.upfronthosting.co.za>
2011-01-05 00:54:33nadeem.vawdalinkissue8052 messages
2011-01-05 00:54:32nadeem.vawdacreate