Re: [PATCH v2 3/5] chain kill signals for cleanup functions
- From
Jeff King <peff@peff.net>
- Date
- Jan 30, 2009, 07:55 UTC
- Message-ID
- <20090130075552.GA27716@coredump.intra.peff.net>
- In-Reply-To
- <20090122060235.GC30133@coredump.intra.peff.net>
On Thu, Jan 22, 2009 at 01:02:35AM -0500, Jeff King wrote:
Show 13 quoted lines
> diff --git a/test-sigchain.c b/test-sigchain.c
> new file mode 100644
> index 0000000..8747dea
> --- /dev/null
> +++ b/test-sigchain.c
> [...]
> +int main(int argc, char **argv) {
> + sigchain_push(SIGINT, one);
> + sigchain_push(SIGINT, two);
> + sigchain_push(SIGINT, three);
> + raise(SIGINT);
> + return 0;
> +}The signal-handling test was failing on my Solaris auto-build. After much painful debugging, it seems that when running without a controlling terminal (such as under cron), the signal handler for terminal related signals (including SIGINT) is initialized to SIG_IGN. Thus after popping all of our signal handlers, we restore the SIG_IGN, the program is _not_ killed by the signal, and the test fails.
One fix would be to just "signal(SIGINT, SIG_DFL)" at the top. But I think it makes the test cleaner to just switch to a more reliable signal. The patch would look something like what is below. But I need to know what exit code Windows generates for SIGTERM. Johannes?
---
diff --git a/t/t0005-signals.sh b/t/t0005-signals.sh index 9707af7..09f855a 100755 --- a/t/t0005-signals.sh +++ b/t/t0005-signals.sh @@ -12,7 +12,7 @@ EOF test_expect_success 'sigchain works' ' test-sigchain >actual case "$?" in - 130) true ;; # POSIX w/ SIGINT=2 + 143) true ;; # POSIX w/ SIGTERM=15 3) true ;; # Windows *) false ;; esac && diff --git a/test-sigchain.c b/test-sigchain.c index 8747dea..42db234 100644 --- a/test-sigchain.c +++ b/test-sigchain.c @@ -14,9 +14,9 @@ X(three) #undef X int main(int argc, char **argv) { - sigchain_push(SIGINT, one); - sigchain_push(SIGINT, two); - sigchain_push(SIGINT, three); - raise(SIGINT); + sigchain_push(SIGTERM, one); + sigchain_push(SIGTERM, two); + sigchain_push(SIGTERM, three); + raise(SIGTERM); return 0; }