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.

classification
Title: subprocess auto-reaps children
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: astrand Nosy List: astrand, awaters, loewis, yorick
Priority: normal Keywords:

Created on 2005-06-04 16:42 by yorick, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg25486 - (view) Author: Mattias Engdegård (yorick) Date: 2005-06-04 16:42
The subprocess module automatically reaps child processes, by 
maintaining a list of instances which is traversed each time a new 
Popen instance is created.

Apparently this was originally intended to avoid large number of 
zombie processes to accrete in the system if the programmer is 
lazy and does not wait for them properly, but it can cause problems 
when the programmer wants greater control. In particular, it's not 
possible to use the pid from a subprocess.Popen instance, since it 
may already have disappeared. For instance, it makes it difficult to 
use os.wait() to wait for several child processes at the same time.

The solution is simple: Add an option that disables the auto-reaper 
for a Popen instance. This makes everyone happy: existing code is 
unaffected, the programmer who wants to control her processes 
herself is allowed to do that, and the documentation is improved to 
help avoiding a nasty bug.

A patch was posted to the patch tracker as number 1187312. I 
suggest it for inclusion into the next release.
msg25487 - (view) Author: Andrew Waters (awaters) Date: 2006-02-02 08:37
Logged In: YES 
user_id=1418249

May want to add a lock in order that auto reaping can 
happen in addition to the use of waitpid.
msg25488 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-04-10 16:04
Logged In: YES 
user_id=21627

Thanks for the report. This is now fixed in r45234.
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 42052
2005-06-04 16:42:25yorickcreate