summaryrefslogtreecommitdiff
path: root/test-skeleton.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-08-14 00:42:51 -0700
committerUlrich Drepper <drepper@redhat.com>2009-08-14 00:42:51 -0700
commit85fda49b9674152ca54d49e0028f981566f2554d (patch)
tree344c0a6f5212cad18c0bca9fcacc5ff65b345967 /test-skeleton.c
parentae0d54500381eb9d40710a259819d9b745a7297f (diff)
downloadglibc-85fda49b9674152ca54d49e0028f981566f2554d.tar.gz
Improve test-skeleton.c to clean up after dead parent.
Diffstat (limited to 'test-skeleton.c')
-rw-r--r--test-skeleton.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/test-skeleton.c b/test-skeleton.c
index 23e40124bd..0238db6b4d 100644
--- a/test-skeleton.c
+++ b/test-skeleton.c
@@ -1,5 +1,5 @@
/* Skeleton for test programs.
- Copyright (C) 1998,2000-2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998,2000-2004, 2005, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -132,7 +132,7 @@ create_temp_file (const char *base, char **filename)
/* Timeout handler. We kill the child and exit with an error. */
static void
__attribute__ ((noreturn))
-timeout_handler (int sig __attribute__ ((unused)))
+signal_handler (int sig __attribute__ ((unused)))
{
int killed;
int status;
@@ -167,6 +167,12 @@ timeout_handler (int sig __attribute__ ((unused)))
CLEANUP_HANDLER;
#endif
+ if (sig == SIGINT)
+ {
+ signal (sig, SIG_DFL);
+ raise (sig);
+ }
+
/* If we expected this signal: good! */
#ifdef EXPECTED_SIGNAL
if (EXPECTED_SIGNAL == SIGALRM)
@@ -325,9 +331,12 @@ main (int argc, char *argv[])
/* Default timeout is two seconds. */
# define TIMEOUT 2
#endif
- signal (SIGALRM, timeout_handler);
+ signal (SIGALRM, signal_handler);
alarm (TIMEOUT * timeoutfactor);
+ /* Make sure we clean up if the wrapper gets interrupted. */
+ signal (SIGINT, signal_handler);
+
/* Wait for the regular termination. */
termpid = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));
if (termpid == -1)