summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-09-30 00:22:13 +0000
committerRoland McGrath <roland@gnu.org>2002-09-30 00:22:13 +0000
commitb79e3737accc6043faefa9a7a3b0080d5f7f05b2 (patch)
treeff4965a095015025b24a430c3919909a253ddf9e
parentd0f82f5d719d3939804071745d4f5192fa380d6b (diff)
downloadglibc-b79e3737accc6043faefa9a7a3b0080d5f7f05b2.tar.gz
glibc-b79e3737accc6043faefa9a7a3b0080d5f7f05b2.tar.xz
glibc-b79e3737accc6043faefa9a7a3b0080d5f7f05b2.zip
2002-09-29 Roland McGrath <roland@redhat.com>
	* test-skeleton.c (timeout_handler): Use WUNTRACED flag in waitpid.
	Examine the child's status and print something different if it wasn't
	just killed by our SIGKILL.
	(main): In the child process call setpgid to put it in its own pgrp.
-rw-r--r--test-skeleton.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/test-skeleton.c b/test-skeleton.c
index e36eee7eb4..a285478ae8 100644
--- a/test-skeleton.c
+++ b/test-skeleton.c
@@ -128,12 +128,13 @@ __attribute__ ((noreturn))
 timeout_handler (int sig __attribute__ ((unused)))
 {
   int killed;
+  int status;
 
   /* Send signal.  */
   kill (pid, SIGKILL);
 
   /* Wait for it to terminate.  */
-  killed = waitpid (pid, NULL, WNOHANG);
+  killed = waitpid (pid, &status, WNOHANG|WUNTRACED);
   if (killed != 0 && killed != pid)
     {
       perror ("Failed to killed test process");
@@ -144,7 +145,17 @@ timeout_handler (int sig __attribute__ ((unused)))
   CLEANUP_HANDLER;
 #endif
 
-  fputs ("Timed out: killed the child process\n", stderr);
+  if (WIFSIGNALED (status) && WTERMSIG (status) == SIGKILL)
+    fputs ("Timed out: killed the child process\n", stderr);
+  else if (WIFSTOPPED (status))
+    fprintf (stderr, "Timed out: the child process was %s\n",
+	     strsignal (WSTOPSIG (status)));
+  else if (WIFSIGNALED (status))
+    fprintf (stderr, "Timed out: the child process got signal %s\n",
+	     strsignal (WTERMSIG (status)));
+  else
+    fprintf (stderr, "Timed out: killed the child process but it exited %d\n",
+	     WEXITSTATUS (status));
 
   /* Exit with an error.  */
   exit (1);
@@ -233,6 +244,10 @@ main (int argc, char *argv[])
       setrlimit (RLIMIT_CORE, &core_limit);
 #endif
 
+      /* We put the test process in its own pgrp so that if it bogusly
+	 generates any job control signals, they won't hit the whole build.  */
+      setpgid (0, 0);
+
       /* Execute the test function and exit with the return value.   */
       exit (TEST_FUNCTION);
     }