selftest: Rework Samba4.pm process termination.
authorAndrew Bartlett <abartlet@samba.org>
Sun, 4 Mar 2012 07:32:44 +0000 (18:32 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 4 Mar 2012 09:14:34 +0000 (10:14 +0100)
We now double-check the waitpid() result with kill(0, $pid)

We now also send a SIGTERM, then a SIGKILL.

Andrew Bartlett

selftest/target/Samba4.pm

index c96662abbc81e1cd5c557dd176c46a62ce940f75..8e276205899952e728d2c3401941472364016285 100644 (file)
@@ -1335,16 +1335,33 @@ sub teardown_env($$)
        $pid = $envvars->{SAMBA_PID};
        my $count = 0;
        my $childpid;
-       until (Samba::cleanup_child($pid, "samba") < 0) {
-           # This should give it time to write out the gcov data
+
+       # This should give it time to write out the gcov data
+       until ($count > 20) {
+           if (Samba::cleanup_child($pid, "samba") == -1) {
+               last;
+           }
            sleep(1);
            $count++;
-           last if $count > 20;
        }
-       
+
+       if ($count <= 20 && kill(0, $pid) == 0) {
+           return;
+       }
+
+       kill "TERM", $pid;
+
+       until ($count > 20) {
+           if (Samba::cleanup_child($pid, "samba") == -1) {
+               last;
+           }
+           sleep(1);
+           $count++;
+       }
+
        # If it is still around, kill it
-       if ($count > 20) {
-           print "server process $pid took more than $count seconds to exit, killing\n";
+       if ($count > 20 && kill(0, $pid) == 0) {
+           warn "server process $pid took more than $count seconds to exit, killing\n";
            kill 9, $pid;
        }