os.system and subprocess odd behavior

Hans Mulder hansmu at xs4all.nl
Tue Dec 18 12:40:44 CET 2012

On 18/12/12 11:39:56, Dave Angel wrote:
> On 12/18/2012 05:27 AM, Hans Mulder wrote:
>> On 18/12/12 06:10:43, photonymous at gmail.com wrote:
>>> I hope I understand the question... but shouldn't you wait for the process to complete before exiting?
>>> Something like:
>>> pid = subprocess.Popen(...)
>>> pid.wait()
>>> Otherwise, it'll exit before the background process is done. 
>> Why would that be a problem?
> Because you don't want to bog the system down with a zombie task.

I think you're confusing zombies with orphans.  A zombie results when
a child exits before the parent and the parent fails to wait for it.
An orphan is what you get if the parent exits before the child does.

On a Un*x system, the 'init' process (the process with ID 1) inherits
orphan processes and collects their exit status when they terminate.
Thus orphans do not become zombies.

I have no idea what would happen under Windows.

Hope this helps,

-- HansM

More information about the Python-list mailing list