From: Michael Adam Date: Fri, 13 May 2016 22:49:40 +0000 (+0200) Subject: selftest: improve logic in cleanup_child() with early return X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=98304a84b7d404a6ac675a7474c9b68ff076a90b;p=metze%2Fsamba%2Fwip.git selftest: improve logic in cleanup_child() with early return Signed-off-by: Michael Adam Reviewed-by: Andreas Schneider --- diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm index 83e2d6b6310e..acdc3623a56d 100644 --- a/selftest/target/Samba.pm +++ b/selftest/target/Samba.pm @@ -313,12 +313,14 @@ sub get_interface($) sub cleanup_child($$) { my ($pid, $name) = @_; - my $childpid = -1; - if (defined($pid)) { - $childpid = waitpid($pid, WNOHANG); + if (!defined($pid)) { + print STDERR "cleanup_child: pid not defined ... not calling waitpid\n"; + return -1; } + my $childpid = waitpid($pid, WNOHANG); + if ($childpid == 0) { } elsif ($childpid < 0) { printf STDERR "%s child process %d isn't here any more\n", $name, $pid;