From 645fcc5375325b700ac58cb25c498f6f7b91421b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 3 Jan 2012 16:48:29 +1100 Subject: selftest: added a pipe on stdin in s3 child processes this adds a pipe for STDIN in smbd, nmbd and winbindd when run in selftest. This allows those processes to detect when they should exit by looking for EOF on stdin. --- selftest/target/Samba3.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'selftest/target/Samba3.pm') diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 45705c0028..4b0b725d52 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -590,6 +590,11 @@ sub read_pid($$) sub check_or_start($$$$$) { my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_; + # use a pipe for stdin in the child processes. This allows + # those processes to monitor the pipe for EOF to ensure they + # exit when the test script exits + pipe(STDIN_READER, $env_vars->{STDIN_PIPE}); + unlink($env_vars->{NMBD_TEST_LOG}); print "STARTING NMBD..."; my $pid = fork(); @@ -631,6 +636,9 @@ sub check_or_start($$$$$) { @preargs = split(/ /, $ENV{NMBD_VALGRIND}); } + close($env_vars->{STDIN_PIPE}); + open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!"; + exec(@preargs, Samba::bindir_path($self, "nmbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!"); } write_pid($env_vars, "nmbd", $pid); @@ -679,6 +687,9 @@ sub check_or_start($$$$$) { print "Starting winbindd with config $env_vars->{SERVERCONFFILE}\n"; + close($env_vars->{STDIN_PIPE}); + open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!"; + exec(@preargs, Samba::bindir_path($self, "winbindd"), "-F", "--no-process-group", "--stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!"); } write_pid($env_vars, "winbindd", $pid); @@ -722,11 +733,17 @@ sub check_or_start($$$$$) { if(defined($ENV{SMBD_VALGRIND})) { @preargs = split(/ /,$ENV{SMBD_VALGRIND}); } + + close($env_vars->{STDIN_PIPE}); + open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!"; + exec(@preargs, Samba::bindir_path($self, "smbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!"); } write_pid($env_vars, "smbd", $pid); print "DONE\n"; + close(STDIN_READER); + return 0; } -- cgit