bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: prevent ignore SIGINT for asynchronous commands without enabling job


From: Dan Douglas
Subject: Re: prevent ignore SIGINT for asynchronous commands without enabling job control
Date: Wed, 10 Apr 2013 06:09:37 -0500
User-agent: KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; )

On Wednesday, April 10, 2013 02:43:12 PM Ilya Basin wrote:
> Hi.
> I have a script that creates some background tasks.
> I want the whole tree to be killed by Ctrl-C.

"tree"? If a script isn't coordinating with its subprocesses manually, then 
the only real guaranteed way to kill a process and all its descendants 
recursively is to use something like Linux cgroups or BSD jails. A tree of 
descendants isn't normally maintained by an OS for each process. You would 
have to go through every running process and walk the PPID chain to build a 
tree, and this will always be racy. 

> There's a requirement that the script process and its children must
> belong to the same process group. This is why I can't enable job
> control.
> 
> I don't want to use 'trap', because it adds complexity.
> 

trap is the standard (only) way to handle signals in shell. They don't have to 
be complicated.

http://mywiki.wooledge.org/ProcessManagement
http://mywiki.wooledge.org/SignalTrap

-- 
Dan Douglas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]