subprocess and PPID

Michele Petrazzo michele.petrazzo at TOGLIunipex.it
Thu Nov 6 03:12:12 EST 2008


saju.pillai at gmail.com wrote:
>> It's possible in linux and with subprocess?
> 
> 
> AFAIK, there is no easy way to do this. If the parent python process 
> is doing a controlled exit, just kill the child via close() on
> Popen() handle.

Like I do ;)

> If the parent is doing a uncontrolled exit (say via a SIGKILL 
> signal), you can't really do anything.
> 

The only thing that I thought it's to use an external resource, like a
.pid file where I save the child pid(s) and, on the next parent startup
control the file and kill the process, if any

> To reliably have the child exit when the parent exits, you would have
>  to poll for the parent from the child and do a exit when the child 
> detects that the parent has gone away.
> 

Like said, I haven't the control of the sources, so I can't.

Thanks,
Michele



More information about the Python-list mailing list