summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-03-04 18:34:34 +1100
committerAndrew Bartlett <abartlet@samba.org>2012-03-04 11:51:12 +0100
commit48e9d7efce1be3b09ed19b3d9a5bf3a3df3800e7 (patch)
treee7eaa97e4985955b65b941553041a34fe44db2b4
parenta37990c5c15e8077c5466ed139044ed26bae8c5e (diff)
downloadsamba-48e9d7efce1be3b09ed19b3d9a5bf3a3df3800e7.tar.gz
samba-48e9d7efce1be3b09ed19b3d9a5bf3a3df3800e7.tar.bz2
samba-48e9d7efce1be3b09ed19b3d9a5bf3a3df3800e7.zip
selftest: Rework Samba3.pm process termination
We now store the timelimit child PID in memory, and confirm that the child has exited with both waitpid() and kill(0, $pid). By calling Samba::cleanup_child() we get exit status information. Andrew Bartlett Autobuild-User: Andrew Bartlett <abartlet@samba.org> Autobuild-Date: Sun Mar 4 11:51:12 CET 2012 on sn-devel-104
-rwxr-xr-xselftest/target/Samba3.pm38
1 files changed, 23 insertions, 15 deletions
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index a5ae8a1bb0..87763aadec 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -48,19 +48,22 @@ sub teardown_env($$)
# This should cause smbd to terminate gracefully
close($envvars->{STDIN_PIPE});
- my $smbdpid = read_pid($envvars, "smbd");
- my $nmbdpid = read_pid($envvars, "nmbd");
- my $winbinddpid = read_pid($envvars, "winbindd");
-
- until (kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
- my $childpid = waitpid(-1, WNOHANG);
- # This should give it time to write out the gcov data
+ my $smbdpid = $envvars->{SMBD_TL_PID};
+ my $nmbdpid = $envvars->{NMBD_TL_PID};
+ my $winbinddpid = $envvars->{WINBINDD_TL_PID};
+
+ # This should give it time to write out the gcov data
+ until ($count > 20) {
+ if (Samba::cleanup_child($smbdpid, "smbd") == -1
+ && Samba::cleanup_child($nmbdpid, "nmbd") == -1
+ && Samba::cleanup_child($winbinddpid, "winbindd") == -1) {
+ last;
+ }
sleep(1);
$count++;
- last if $childpid == -1 or $count > 20;
}
- if ($count <= 20) {
+ if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
return;
}
@@ -69,15 +72,17 @@ sub teardown_env($$)
$self->stop_sig_term($winbinddpid);
$count = 0;
- until (kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
- # if no process sucessfully signalled, then we are done
- my $childpid = waitpid(-1, WNOHANG);
+ until ($count > 10) {
+ if (Samba::cleanup_child($smbdpid, "smbd") == -1
+ && Samba::cleanup_child($nmbdpid, "nmbd") == -1
+ && Samba::cleanup_child($winbinddpid, "winbindd") == -1) {
+ last;
+ }
sleep(1);
$count++;
- last if $childpid == -1 or $count > 20;
}
-
- if ($count <= 10) {
+
+ if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
return;
}
@@ -591,6 +596,7 @@ sub check_or_start($$$$$) {
exec(@preargs, Samba::bindir_path($self, "nmbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!");
}
+ $env_vars->{NMBD_TL_PID} = $pid;
write_pid($env_vars, "nmbd", $pid);
print "DONE\n";
@@ -642,6 +648,7 @@ sub check_or_start($$$$$) {
exec(@preargs, Samba::bindir_path($self, "winbindd"), "-F", "--no-process-group", "--stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!");
}
+ $env_vars->{WINBINDD_TL_PID} = $pid;
write_pid($env_vars, "winbindd", $pid);
print "DONE\n";
@@ -689,6 +696,7 @@ sub check_or_start($$$$$) {
exec(@preargs, Samba::bindir_path($self, "smbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!");
}
+ $env_vars->{SMBD_TL_PID} = $pid;
write_pid($env_vars, "smbd", $pid);
print "DONE\n";