Multiprocessing: killing children when parent dies

Mihai Badoiu mbadoiu at gmail.com
Wed Dec 7 14:00:20 EST 2011


ok, so the code is something like
#process A
  p = Process(...)
  p.daemon = 1
  p.start()   # starts process B
...

If process A dies (say error, or ctrl-c), or finishes, then process B also
dies.  But if process A is killed with the "kill" command, then process B
soldiers on...

Any idea on how to make process B die when process A gets killed by the
"kill" command?

thanks,

--mihai

On Sat, Dec 3, 2011 at 4:01 AM, Jack Keegan <whatsjacksemail at gmail.com>wrote:

> I think the OP meant when the parent gets killed (by ctrl+c or similar),
> not deleted. At least that's what I think when I think of a program being
> killed. Is it even possible to send a signal in such a case?
>
> Cheers,
>
> Jack
>
> On Fri, Dec 2, 2011 at 4:27 PM, 88888 Dihedral <
> dihedral88888 at googlemail.com> wrote:
>
>> Please check Erlang that spawn so easily. And there are Python packages
>> can do the same task.
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
>
> --
> The earth is a very small stage in a vast cosmic arena. Think of the
> rivers of blood spilled by all those generals and emperors so that in glory
> and in triumph they could become the momentary masters of a fraction of a
> dot.
> - Carl Sagan [Pale Blue Dot]
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111207/4a2e6f40/attachment-0001.html>


More information about the Python-list mailing list