This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nadeem.vawda
Recipients gregory.p.smith, jyasskin, loewis, nadeem.vawda, neologix, pitrou, rosslagerwall, s7v7nislands, vstinner
Date 2011-03-29.21:28:16
SpamBayes Score 0.0
Marked as misclassified No
Message-id <1301434097.07.0.241748121227.issue8052@psf.upfronthosting.co.za>
In-reply-to
Content
> For what its worth, an strace of Java's Process class appears to "cheat" by
> opening /proc/self/fd inbetween fork & exec.

Looking at the OpenJDK source confirms this:
http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/tip/src/solaris/native/java/lang/UNIXProcess_md.c

I wonder whether the Java people are simply unaware of the potential problem?
Or perhaps they have checked the Linux and Solaris implementations of readdir()
and confirmed that it is in fact safe on those platforms. Even if this is the
case, I would be wary of doing things the same way - there's no guarantee that
the implementation won't change out from underneath us.

I like the approach suggested by Gregory in issue11284 (msg129912) - if we are
sure the program is not multithreaded, get the list of fds before forking, and
use that; otherwise, do it the slow way.

On Linux, the multithreading check could be implemented by checking the number
of subdirectories in /proc/<pid>/task/. I don't know if *BSD (or other Unices)
have a similar way to do this. Some quick Googling seems to indicate that
FreeBSD, at least, doesn't make this information available through the procfs
(which is apparently deprecated anyway). Could someone with wider *nix
knowledge chip in here?
History
Date User Action Args
2011-03-29 21:28:17nadeem.vawdasetrecipients: + nadeem.vawda, loewis, gregory.p.smith, pitrou, vstinner, jyasskin, s7v7nislands, neologix, rosslagerwall
2011-03-29 21:28:17nadeem.vawdasetmessageid: <1301434097.07.0.241748121227.issue8052@psf.upfronthosting.co.za>
2011-03-29 21:28:16nadeem.vawdalinkissue8052 messages
2011-03-29 21:28:16nadeem.vawdacreate