]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
selftest: Parameterize clean up in the child process
authorVolker Lendecke <vl@samba.org>
Thu, 30 Jan 2020 14:49:59 +0000 (15:49 +0100)
committerMartin Schwenke <martins@samba.org>
Wed, 19 Feb 2020 09:38:40 +0000 (09:38 +0000)
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>
selftest/target/Samba.pm

index 26b838981f664f24eb5eb442cf8c5046210311b7..15d825bba07b62e36e239723187349ce8e14a7af 100644 (file)
@@ -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