Avoiding defunct processes

Nobody nobody at nowhere.com
Fri Nov 2 16:46:04 CET 2012


On Thu, 01 Nov 2012 19:16:17 -0700, Richard wrote:

> I create child processes with subprocess.Popen().
> Then I either wait for them to finish or kill them.
> Either way these processes end up as defunct until the parent process
> completes:
> $ ps e
> 6851 pts/5    Z+     1:29 [python] <defunct>

You need to either call the .wait() method, or keep calling the .poll()
method until the .returncode attribute is not None.



More information about the Python-list mailing list