selftest: Fix selftest where pid is used uninitialized.
authorAndreas Schneider <asn@samba.org>
Thu, 4 Sep 2014 10:55:53 +0000 (12:55 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 4 Sep 2014 15:09:17 +0000 (17:09 +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

selftest/target/Samba.pm

index d33c1d68672aa78225436af4c1b367867b6e0c4b..2bd90ae6f992fd988ebbddaf83c51da7e21ee2a3 100644 (file)
@@ -190,7 +190,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",