end child process when parent dies (on Unix)

Miles semanticist at gmail.com
Mon Nov 17 21:49:16 EST 2008


On Mon, Nov 17, 2008 at 2:51 AM, Дамјан Георгиевски wrote:
>>> I'm starting a Unix tool with subprocess.Popen() from a python script
>>> and I want the child to be killed when the parent (my script) ends
>>> for whatever reason *including* if it gets killed by SIGKILL.
>>
>> A Linux-specific solution is prctl(2).
>
> I've tried this in a test C program... exactly what I need. Now if I
> could slip this between the fork and exec in subprocess.Popen()

preexec_fn, perhaps?

http://docs.python.org/library/subprocess.html#using-the-subprocess-module

-Miles


More information about the Python-list mailing list