Skip to content

Commit 9f7cbd9

Browse files
committed
Handle child process failing
When a child process fails, e.g. with a FatalError, it might still return empty list of errors. Although, child process failure is definitely not a thing we want to ignore. Therefore, we check exit status of each child process and make sure parent process fails (and returns non-zero status code) as well.
1 parent f3a8342 commit 9f7cbd9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Runner.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,14 +713,22 @@ private function processChildProcs($childProcs)
713713
$numProcessed = 0;
714714
$totalBatches = count($childProcs);
715715

716-
$success = true;
716+
$success = true;
717+
$childProcessFailed = false;
717718

718719
while (count($childProcs) > 0) {
719720
$pid = pcntl_waitpid(0, $status);
721+
720722
if ($pid <= 0) {
721723
continue;
722724
}
723725

726+
$childProcessStatus = pcntl_wexitstatus($status);
727+
728+
if ($childProcessStatus !== 0) {
729+
$childProcessFailed = true;
730+
}
731+
724732
$out = $childProcs[$pid];
725733
unset($childProcs[$pid]);
726734
if (file_exists($out) === false) {
@@ -768,7 +776,7 @@ private function processChildProcs($childProcs)
768776
$this->printProgress($file, $totalBatches, $numProcessed);
769777
}//end while
770778

771-
return $success;
779+
return $success && !$childProcessFailed;
772780

773781
}//end processChildProcs()
774782

0 commit comments

Comments
 (0)