[git commit] test: update test-skeleton.c

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Thu Mar 14 21:49:25 UTC 2013


commit: http://git.uclibc.org/uClibc/commit/?id=74dd5ff42ccbccfbca98fc9c7addf3da1c8a6856
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 test/test-skeleton.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/test/test-skeleton.c b/test/test-skeleton.c
index 1c3badb..3eab1b8 100644
--- a/test/test-skeleton.c
+++ b/test/test-skeleton.c
@@ -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 = 0;
   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)
@@ -189,6 +195,7 @@ timeout_handler (int sig __attribute__ ((unused)))
   exit (1);
 }
 
+#ifdef __XXX_HANDLE_CTRL_C
 static void
 __attribute__ ((noreturn))
 handler_killpid(int sig)
@@ -198,6 +205,7 @@ handler_killpid(int sig)
 	raise(sig); /* kill ourself */
 	_exit(128 + sig); /* paranoia */
 }
+#endif
 
 /* We provide the entry point here.  */
 int
@@ -344,18 +352,23 @@ main (int argc, char *argv[])
       exit (1);
     }
 
+#ifdef __XXX_HANDLE_CTRL_C
   signal (SIGTERM, handler_killpid);
   signal (SIGINT, handler_killpid);
   signal (SIGQUIT, handler_killpid);
+#endif
 
   /* Set timeout.  */
 #ifndef TIMEOUT
   /* 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)


More information about the uClibc-cvs mailing list