Skip to content

Commit

Permalink
[Process] Fix silencing wait when using a sigchild-enabled binary
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Aug 7, 2023
1 parent ce9850f commit 45261e1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public function start(callable $callback = null, array $env = [])

// See https://unix.stackexchange.com/questions/71205/background-process-pipe-input
$commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
$commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
$commandline .= 'pid=$!; echo $pid >&3; wait $pid 2>/dev/null; code=$?; echo $code >&3; exit $code';

// Workaround for the bug, when PTS functionality is enabled.
// @see : https://bugs.php.net/69442
Expand Down
2 changes: 1 addition & 1 deletion Tests/ProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ public function testWaitStoppedDeadProcess()
$process->wait();
$this->assertFalse($process->isRunning());

if ('\\' !== \DIRECTORY_SEPARATOR) {
if ('\\' !== \DIRECTORY_SEPARATOR && !\Closure::bind(function () { return $this->isSigchildEnabled(); }, $process, $process)()) {
$this->assertSame(0, $process->getExitCode());
}
}
Expand Down

0 comments on commit 45261e1

Please sign in to comment.