Hello,
what do you think about the following way to remove the sigs_to_ignore
hack in the timeout.c file?
It ignores temporarily the signal inside the `send_sig' function instead
of using the `sigs_to_ignore' array.
Regards,
Giuseppe Scrivano
diff --git a/src/timeout.c b/src/timeout.c
index 8b506f0..93b23f6 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -82,7 +82,8 @@
static int timed_out;
static int term_signal = SIGTERM; /* same default as kill command. */
static int monitored_pid;
-static int sigs_to_ignore[NSIG]; /* so monitor can ignore sigs it resends.
*/
+
+static void cleanup (int sig);
static struct option const long_options[] =
{
@@ -90,13 +91,25 @@ static struct option const long_options[] =
{NULL, 0, NULL, 0}
};
-/* send sig to group but not ourselves.
- * FIXME: Is there a better way to achieve this? */
+/* send sig to group but not ourselves. */
static int
send_sig (int where, int sig)
{
- sigs_to_ignore[sig] = 1;
- return kill (where, sig);
+ int ret;
+ struct sigaction sa;
+ void (*handler)(int);
+
+ sigaction (sig, NULL, &sa);
+ handler = sa.sa_handler;
+ sa.sa_handler = SIG_IGN;
+ sigaction (sig, &sa, NULL);
+
+ ret = kill (where, sig);
+
+ sa.sa_handler = handler;
+ sigaction (sig, &sa, NULL);
+
+ return ret;
}
static void
@@ -109,11 +122,6 @@ cleanup (int sig)
}
if (monitored_pid)
{
- if (sigs_to_ignore[sig])
- {
- sigs_to_ignore[sig] = 0;
- return;
- }
send_sig (0, sig);
if (sig != SIGKILL && sig != SIGCONT)
send_sig (0, SIGCONT);
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils