Eradicate race condition in t/op/sigsystem.t (#114562)
authorLeon Timmermans <fawaka@gmail.com>
Wed, 12 Sep 2012 13:38:44 +0000 (15:38 +0200)
committerLeon Timmermans <fawaka@gmail.com>
Wed, 12 Sep 2012 13:41:42 +0000 (15:41 +0200)
t/op/sigsystem.t

index 197ecb2..ddfebf9 100644 (file)
@@ -17,6 +17,13 @@ SKIP: {
     require POSIX;
     require Time::HiRes;
 
+    my @pids;
+    $SIG{CHLD} = sub {
+       while ((my $child = waitpid(-1, POSIX::WNOHANG())) > 0) {
+           note "Reaped: $child";
+           push @pids, $child;
+       }
+    };
     my $pid = fork // die "Can't fork: $!";
     unless ($pid) {
        note("Child PID: $$");
@@ -26,14 +33,6 @@ SKIP: {
 
     test_system('without reaper');
 
-    my @pids;
-    $SIG{CHLD} = sub {
-       while ((my $child = waitpid(-1, POSIX::WNOHANG())) > 0) {
-           note "Reaped: $child";
-           push @pids, $child;
-       }
-    };
-
     test_system('with reaper');
 
     note("Waiting briefly for SIGCHLD...");