[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] timeout: don't orphan monitored programs if they ignore specifie
From: |
Pádraig Brady |
Subject: |
[PATCH] timeout: don't orphan monitored programs if they ignore specified signals |
Date: |
Fri, 23 Oct 2009 10:17:40 +0100 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20071008) |
Without this, the following would leave an orphaned dd process spinning away:
timeout -sUSR1 1s dd if=/dev/zero of=/dev/null
cheers,
Pádraig.
>From 6fc9e94d4442f8f55728c80d750a944fa21cb16d Mon Sep 17 00:00:00 2001
From: =?utf-8?q?P=C3=A1draig=20Brady?= <address@hidden>
Date: Fri, 23 Oct 2009 08:52:25 +0100
Subject: [PATCH] timeout: don't orphan monitored programs if they ignore
specified signals
* src/timeout.c (install_signal_handlers): Handle any user
specified termination signal, so that if the child ignores it we
will not exit, thus orphaning the child. Previously this
would leave an orphan dd process running:
timeout -sUSR1 1s dd if=/dev/zero of=/dev/null
* NEWS: Mention the fix.
---
NEWS | 3 +++
src/timeout.c | 7 ++++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index 29bedac..32a2a56 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,9 @@ GNU coreutils NEWS -*-
outline -*-
This also affected sum, sha1sum, sha224sum, sha384sum and sha512sum.
[the bug dates back to the initial implementation]
+ timeout now doesn't exit unless the command it is monitoring does,
+ for all specified signals. [bug introduced in coreutils-7.0].
+
** New features
md5sum --check now also accepts openssl-style checksums.
diff --git a/src/timeout.c b/src/timeout.c
index 7b0f1d7..3babb8c 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -196,7 +196,7 @@ apply_time_suffix (unsigned long *x, char suffix_char)
}
static void
-install_signal_handlers (void)
+install_signal_handlers (int sigterm)
{
struct sigaction sa;
sigemptyset(&sa.sa_mask); /* Allow concurrent calls to handler */
@@ -206,8 +206,9 @@ install_signal_handlers (void)
sigaction (SIGALRM, &sa, NULL); /* our timeout. */
sigaction (SIGINT, &sa, NULL); /* Ctrl-C at terminal for example. */
sigaction (SIGQUIT, &sa, NULL); /* Ctrl-\ at terminal for example. */
- sigaction (SIGTERM, &sa, NULL); /* if we're killed, stop monitored proc. */
sigaction (SIGHUP, &sa, NULL); /* terminal closed for example. */
+ sigaction (SIGTERM, &sa, NULL); /* if we're killed, stop monitored proc. */
+ sigaction (sigterm, &sa, NULL); /* user specified termination signal. */
}
int
@@ -271,7 +272,7 @@ main (int argc, char **argv)
/* Setup handlers before fork() so that we
handle any signals caused by child, without races. */
- install_signal_handlers ();
+ install_signal_handlers (term_signal);
signal (SIGTTIN, SIG_IGN); /* don't sTop if background child needs tty.
*/
signal (SIGTTOU, SIG_IGN); /* don't sTop if background child needs tty.
*/
--
1.6.2.5
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] timeout: don't orphan monitored programs if they ignore specified signals,
Pádraig Brady <=