smbtorture: Do not leak child processes when exiting
authorChristof Schmitt <christof.schmitt@us.ibm.com>
Thu, 15 Dec 2011 20:53:48 +0000 (13:53 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 2 Feb 2012 00:35:27 +0000 (01:35 +0100)
When some child processes could not be created, smbtorture would exit
and leave the successfully started child processes running.  Add a loop
to kill the existing child processes for this case.

Signed-off-by: Jeremy Allison <jra@samba.org>
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Thu Feb  2 01:35:27 CET 2012 on sn-devel-104

source4/torture/util_smb.c

index c9a4a0e1b2b78b7ca0005ac53976c1d30acb419f..9efa33437ccf4aa48ff5a576a4720f1aace8438f 100644 (file)
@@ -729,6 +729,14 @@ double torture_create_procs(struct torture_context *tctx,
 
        if (synccount != torture_nprocs) {
                printf("FAILED TO START %d CLIENTS (started %d)\n", torture_nprocs, synccount);
+
+               /* cleanup child processes */
+               for (i = 0; i < torture_nprocs; i++) {
+                       if (child_status[i]) {
+                               kill(child_status[i], SIGTERM);
+                       }
+               }
+
                *result = false;
                return timeval_elapsed(&tv);
        }