Killing child processes with Upstart

James Hunt james.hunt at ubuntu.com
Tue May 8 15:33:22 UTC 2012


On 05/07/12 14:40, Evgen Koval wrote:
> Hello !
> I have a script written in Python, which spawns some child processes and manages them then. One of it's tasks is to terminate all child processes and wait until all of them died.
> I use Upstart to run this script, here is my .conf:
> **********
> exec python /usr/scraper/scraper/manager.py
> kill timeout 20
> **********
> 
> The problem is that when I type "stop <task>", Upstart sends stop signal not to only master process, but all child processes as well.
> This is not very good for me, because I'd like manager to control child processes.
> 
> The question is:
> Is it possible to tell Upstart not to touch child processes and send TERM signal only to master process ?
> 
> Thanks
> 
> Eugene
> 
> 
Hi Eugene,

You can't change the fact that Upstart will kill the entire process group the parent PID belongs to.
However, using a 'pre-stop' stanza you could arrange for the parent to shut down its children first:

	http://upstart.ubuntu.com/cookbook/#pre-stop

Kind regards,

James
--
James Hunt
____________________________________
http://upstart.ubuntu.com/cookbook
http://upstart.ubuntu.com/cookbook/upstart_cookbook.pdf



More information about the upstart-devel mailing list