diff options
author | Andrew Bartlett <abartlet@samba.org> | 2012-03-04 17:30:45 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2012-03-04 10:14:34 +0100 |
commit | d715e2c2948cf642e725bee56f1f43e2395a2025 (patch) | |
tree | 328d81fb5656d1bb703f87c43894b9a1cd3ad394 /selftest/target/Samba.pm | |
parent | 769cee44a2ed1b68cb757246efd72d63aa36a4d0 (diff) | |
download | samba-d715e2c2948cf642e725bee56f1f43e2395a2025.tar.gz samba-d715e2c2948cf642e725bee56f1f43e2395a2025.tar.bz2 samba-d715e2c2948cf642e725bee56f1f43e2395a2025.zip |
selftest: Use fork()/exec() rather than system()
This follows the Samba3.pm model for starting child processes is to
use fork()/exec(). This reduces the number of processes being created
by selftest.pl, and gives us more information about the child process
and the running state in the parent.
Andrew Bartlett
Diffstat (limited to 'selftest/target/Samba.pm')
-rw-r--r-- | selftest/target/Samba.pm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm index 06b6472a6c..14226036a1 100644 --- a/selftest/target/Samba.pm +++ b/selftest/target/Samba.pm @@ -8,6 +8,7 @@ package Samba; use strict; use target::Samba3; use target::Samba4; +use POSIX; sub new($$$$$) { my ($classname, $bindir, $binary_mapping,$ldap, $srcdir, $server_maxtime) = @_; @@ -172,4 +173,23 @@ sub get_interface($) return $interfaces{$netbiosname}; } + +sub cleanup_child($$) +{ + my ($pid, $name) = @_; + my $childpid = waitpid($pid, WNOHANG); + if ($childpid == 0) { + } elsif ($childpid < 0) { + printf STDERR "%s child process %d isn't here any more\n", + return $childpid; + } + elsif ($? & 127) { + printf STDERR "%s child process %d, died with signal %d, %s coredump\n", + $name, $childpid, ($? & 127), ($? & 128) ? 'with' : 'without'; + } else { + printf STDERR "%s child process %d exited with value %d\n", $name, $childpid, $? >> 8; + } + return $childpid; +} + 1; |