selftest: Fix selftest where pid is used uninitialized.
authorAndreas Schneider <asn@samba.org>
Thu, 4 Sep 2014 10:55:53 +0000 (12:55 +0200)
committerKarolin Seeger <kseeger@samba.org>
Thu, 11 Sep 2014 20:02:42 +0000 (22:02 +0200)
On my system this gets evaluated to 0 so in the end we detect samba to
be running cause $childpid is set to 0.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=10793

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Sep  4 17:09:17 CEST 2014 on sn-devel-104

(cherry picked from commit 6d2f56dbaf84203b351f33179cc3feaf557e0683)
Signed-off-by: Andreas Schneider <asn@samba.org>
Autobuild-User(v4-0-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-0-test): Thu Sep 11 22:02:42 CEST 2014 on sn-devel-104

selftest/target/Samba.pm

index d8110536b2a32f56b72dd49faf94c301406d94f7..5f18a47dd4d8d66d540bd98b43d1752bd13c3879 100644 (file)
@@ -186,7 +186,12 @@ sub get_interface($)
 sub cleanup_child($$)
 {
     my ($pid, $name) = @_;
-    my $childpid = waitpid($pid, WNOHANG);
+    my $childpid = -1;
+
+    if (defined($pid)) {
+        $childpid = waitpid($pid, WNOHANG);
+    }
+
     if ($childpid == 0) {
     } elsif ($childpid < 0) {
        printf STDERR "%s child process %d isn't here any more\n",