summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2011-07-08 13:31:05 +0100
committerPádraig Brady <P@draigBrady.com>2011-07-08 13:54:08 +0100
commit4d90d29899917ec16ea5806a0456501e5e948960 (patch)
tree3af0b546d5b32d0fe761037546866ad9ff9a4621 /src
parent4496c94091f8a6bc95fc1c0868eba632fae99ba3 (diff)
downloadcoreutils-4d90d29899917ec16ea5806a0456501e5e948960.tar.xz
timeout: support cascaded timeouts
* src/timeout.c (cleanup): Send signals directly to the child in case it has started its own process group (like a cascaded timeout command would for example). * test/misc/timeout-group: Add a test case. * NEWS: Mention the fix.
Diffstat (limited to 'src')
-rw-r--r--src/timeout.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/timeout.c b/src/timeout.c
index 8f0980b96..ab54ed675 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -104,8 +104,6 @@ cleanup (int sig)
}
if (monitored_pid)
{
- int where = foreground ? monitored_pid : 0;
-
if (sigs_to_ignore[sig])
{
sigs_to_ignore[sig] = 0;
@@ -119,9 +117,20 @@ cleanup (int sig)
kill_after = 0; /* Don't let later signals reset kill alarm. */
}
- send_sig (where, sig);
+ /* Send the signal directly to the monitored child,
+ in case it has itself become group leader,
+ or is not running in a separate group. */
+ send_sig (monitored_pid, sig);
+ /* The normal case is the job has remained in our
+ newly created process group, so send to all processes in that. */
+ if (!foreground)
+ send_sig (0, sig);
if (sig != SIGKILL && sig != SIGCONT)
- send_sig (where, SIGCONT);
+ {
+ send_sig (monitored_pid, SIGCONT);
+ if (!foreground)
+ send_sig (0, SIGCONT);
+ }
}
else /* we're the child or the child is not exec'd yet. */
_exit (128 + sig);