By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,199 Members | 1,125 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,199 IT Pros & Developers. It's quick & easy.

Re: end child process when parent dies (on Unix)

P: n/a
Дамјан Георгиевски 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).
Nov 17 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
>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()
--
дамјан ( http://softver.org.mk/damjan/ )

In theory, there is no difference between theory and practice.
But, in practice, there is.
Nov 17 '08 #2

P: n/a
Дамјан Георгиевски 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()
An obvious way, if you're trying to hack something without the source, is to substitute your own executable which does the prctl before execing the real executable.
Nov 17 '08 #3

P: n/a
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/subpr...process-module

-Miles
Nov 18 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.