From 45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 7 Aug 2023 11:52:08 +0200 Subject: [PATCH] [Process] Fix silencing `wait` when using a sigchild-enabled binary --- Process.php | 2 +- Tests/ProcessTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Process.php b/Process.php index 9b19475a..30ebeb6b 100644 --- a/Process.php +++ b/Process.php @@ -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 diff --git a/Tests/ProcessTest.php b/Tests/ProcessTest.php index 827c7239..80493799 100644 --- a/Tests/ProcessTest.php +++ b/Tests/ProcessTest.php @@ -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()); } }