summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2020-01-30 15:49:59 +0100
committerMartin Schwenke <martins@samba.org>2020-02-19 09:38:40 +0000
commitff5dd4bb4facf7bf37b0ea2d16787bfc3268dd03 (patch)
tree94655cfeb8f0a55da7f0de606e6758a48aa6856e
parent586189ab69850dc292cea874f6a115851323a57c (diff)
downloadsamba-ff5dd4bb4facf7bf37b0ea2d16787bfc3268dd03.tar.gz
selftest: Parameterize clean up in the child process
Default to closing the write end of the parent->child pipe. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
-rw-r--r--selftest/target/Samba.pm13
1 files 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