]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
test-skeleton: Kill any child process's offspring
authorMaciej W. Rozycki <macro@codesourcery.com>
Mon, 30 Jun 2014 19:05:34 +0000 (20:05 +0100)
committerMaciej W. Rozycki <macro@codesourcery.com>
Mon, 30 Jun 2014 19:11:56 +0000 (20:11 +0100)
This makes sure any subprocesses created by the program being tested get
killed as well if their parent times out.  Otherwise if they are really
stuck, they may remain there running forever after the test case and
then the whole test suite has completed, until killed by hand.

* test-skeleton.c (signal_handler): Kill the whole process group
before killing the child individually.
(main): Report any failure on `setpgid'.

ChangeLog
test-skeleton.c

index 785baf996b2871861e4c7d0672bdb4adc6ab36fe..b2ea30c235d68664fb908bc9a4b0babb11d2db6b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-06-30  Maciej W. Rozycki  <macro@codesourcery.com>
+           Roland McGrath <roland@hack.frob.com>
+
+       * test-skeleton.c (signal_handler): Kill the whole process group
+       before killing the child individually.
+       (main): Report any failure on `setpgid'.
+
 2014-06-30  Roland McGrath  <roland@hack.frob.com>
 
        * sysdeps/arm/nptl/tls.h: Rename the multiple inclusion guard
index 286d1419cfca506dfe29390ed81e57eac9e428f1..c1278ca3b2c07673f80c6116bc436b01d93a30ff 100644 (file)
@@ -17,6 +17,7 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
@@ -138,7 +139,10 @@ signal_handler (int sig __attribute__ ((unused)))
   int killed;
   int status;
 
-  /* Send signal.  */
+  assert (pid > 1);
+  /* Kill the whole process group.  */
+  kill (-pid, SIGKILL);
+  /* In case setpgid failed in the child, kill it individually too.  */
   kill (pid, SIGKILL);
 
   /* Wait for it to terminate.  */
@@ -342,7 +346,8 @@ main (int argc, char *argv[])
 
       /* 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);
+      if (setpgid (0, 0) != 0)
+       printf ("Failed to set the process group ID: %m\n");
 
       /* Execute the test function and exit with the return value.   */
       exit (TEST_FUNCTION);