> Can the subprocess module be used to launch subprocesses from threads?
The answer to this question ("can") is a clear yes. Notice that this question is different from the question in the subject. > Or does the subprocess module affect the entire process context, like > "fork"? On POSIX systems, it uses fork(2) - what else could it do? I'm not sure what effects to the entire process context you are referring to. In a POSIX system, you can also fork from a thread just fine. > Or is this OS dependent? The precise semantics are OS dependent, yes. However, you can use it in the presence of threads on most systems that support threads (for a reasonable definition of "supports threads", which may exclude HP-UX and FreeBSD :-) It's technically not thread-safe if other threads manipulate file descriptors; there is always a chance of race conditions when some thread opens a file handle and then tries to set the CLOEXEC flag on it - if some other thread creates a subprocess in-between, there is a chance that the child process "sees" the file handle even though it "should" have the CLOEXEC flag set (but didn't at the point when the process forked). > Also, if you launch processes from the subprocess module module and > don't wait them to complete, do zombies accumulate under UNIX/Linux? No. It depends on the precise code, but if you drop the reference to the Popen object, or call one of the functions that don't return one in the first place, the module itself will wait for the child processes "regularly". Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list