Nadeem Vawda <nadeem.va...@gmail.com> added the comment:

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

----------
nosy: +nvawda

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8052>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to