From ce9850f4eafd1181427f005a8b238d943878e53c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 1 Aug 2023 15:39:00 +0200 Subject: [PATCH 1/2] [Process] Fix test case --- Tests/ErrorProcessInitiator.php | 4 ++-- Tests/ProcessTest.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Tests/ErrorProcessInitiator.php b/Tests/ErrorProcessInitiator.php index 4c8556ac..54168022 100644 --- a/Tests/ErrorProcessInitiator.php +++ b/Tests/ErrorProcessInitiator.php @@ -14,12 +14,12 @@ use Symfony\Component\Process\Exception\ProcessTimedOutException; use Symfony\Component\Process\Process; -require \dirname(__DIR__).'/vendor/autoload.php'; +require is_file(\dirname(__DIR__).'/vendor/autoload.php') ? \dirname(__DIR__).'/vendor/autoload.php' : \dirname(__DIR__, 5).'/vendor/autoload.php'; ['e' => $php] = getopt('e:') + ['e' => 'php']; try { - $process = new Process("exec $php -r \"echo 'ready'; trigger_error('error', E_USER_ERROR);\""); + $process = new Process([$php, '-r', "echo 'ready'; trigger_error('error', E_USER_ERROR);"]); $process->start(); $process->setTimeout(0.5); while (!str_contains($process->getOutput(), 'ready')) { diff --git a/Tests/ProcessTest.php b/Tests/ProcessTest.php index 6e6ee8a4..827c7239 100644 --- a/Tests/ProcessTest.php +++ b/Tests/ProcessTest.php @@ -1523,6 +1523,10 @@ public function testWaitStoppedDeadProcess() $process->setTimeout(2); $process->wait(); $this->assertFalse($process->isRunning()); + + if ('\\' !== \DIRECTORY_SEPARATOR) { + $this->assertSame(0, $process->getExitCode()); + } } public function testEnvCaseInsensitiveOnWindows() From 45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 7 Aug 2023 11:52:08 +0200 Subject: [PATCH 2/2] [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()); } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy