From ff5dd4bb4facf7bf37b0ea2d16787bfc3268dd03 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 30 Jan 2020 15:49:59 +0100 Subject: selftest: Parameterize clean up in the child process Default to closing the write end of the parent->child pipe. Signed-off-by: Volker Lendecke Reviewed-by: Martin Schwenke --- selftest/target/Samba.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm index 26b838981f6..15d825bba07 100644 --- a/selftest/target/Samba.pm +++ b/selftest/target/Samba.pm @@ -672,10 +672,16 @@ sub get_env_for_process sub fork_and_exec { - my ($self, $env_vars, $daemon_ctx, $STDIN_READER) = @_; + my ($self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup) = @_; my $SambaCtx = $self; $SambaCtx = $self->{SambaCtx} if defined($self->{SambaCtx}); + # 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. + $child_cleanup //= sub { close($env_vars->{STDIN_PIPE}) }; + unlink($daemon_ctx->{LOG_FILE}); print "STARTING $daemon_ctx->{NAME} for $ENV{ENVNAME}..."; @@ -706,10 +712,7 @@ 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}); + $child_cleanup->(); # not all s3 daemons run in all testenvs (e.g. fileserver doesn't # run winbindd). In which case, the child process just sleeps -- cgit v1.2.1