closing popen2

Padraig at Linux.ie Padraig at Linux.ie
Tue May 6 09:04:41 EDT 2003


Cipo Fuzo wrote:
> Hello,
> 
> How do I close a process opened with popen2?
> I do:
> 
> proc = popen2(cmd)
> proc[0].close()
> proc[1].close()
> 
> but this doesn't end 'cmd'. When I do a ps in the shell, I
> can still see
> 
> [cmd <defunct>]

This mean's you haven't waited for the child.
The next time you run popen2() the child will
be reaped. If you want to be neater you can
use the popen2.Popen3 class, and then do
childobject.wait().

Note you may have to write your own as
I did for: http://www.pixelbeat.org/fslint

Pádraig.





More information about the Python-list mailing list