From: Volker Lendecke Date: Tue, 28 Jan 2020 13:41:11 +0000 (+0100) Subject: selftest: Close STDIN_PIPE's write end for skipped daemons X-Git-Tag: ldb-2.1.1~230 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5bc5b681c037ed1e8e119b7c062ab397bafb9571;p=thirdparty%2Fsamba.git selftest: Close STDIN_PIPE's write end for skipped daemons Without this, any environment that skips any daemon will not shut down properly. If a copy of a pipe's write end remains, closing one of them won't cause the read end to be readable, i.e. the daemons waiting for that won't exit properly. Signed-off-by: Volker Lendecke Reviewed-by: Andrew Bartlett --- diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm index 9319f301327..216c13f11c1 100644 --- a/selftest/target/Samba.pm +++ b/selftest/target/Samba.pm @@ -664,6 +664,11 @@ sub fork_and_exec set_env_for_process($daemon_ctx->{NAME}, $env_vars, $daemon_ctx->{ENV_VARS}); + # we close the child's write-end of the pipe and redirect the read-end + # to its stdin. That way the daemon will receive an EOF on stdin when + # parent selftest process closes its write-end. + close($env_vars->{STDIN_PIPE}); + # not all s3 daemons run in all testenvs (e.g. fileserver doesn't # run winbindd). In which case, the child process just sleeps if (defined($daemon_ctx->{SKIP_DAEMON})) { @@ -678,10 +683,6 @@ sub fork_and_exec $ENV{MAKE_TEST_BINARY} = $daemon_ctx->{BINARY_PATH}; - # we close the child's write-end of the pipe and redirect the read-end - # to its stdin. That way the daemon will receive an EOF on stdin when - # parent selftest process closes its write-end. - close($env_vars->{STDIN_PIPE}); open STDIN, ">&", $STDIN_READER or die "can't dup STDIN_READER to STDIN: $!"; # if using kernel namespaces, prepend the command so the process runs in