8000 Fix Inconsistent Exit Status in `proc_get_status` for PHP Versions Below 8.3 by Luc45 · Pull Request #53820 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Code style
  • Loading branch information
Luc45 authored Feb 7, 2024
commit 8b376d367598d0e96c303d27207b93ddd79931ea
8 changes: 4 additions & 4 deletions src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -1292,19 +1292,19 @@ protected function updateStatus(bool $blocking): void

$running = $this->processInformation['running'];

/*
/*
* In PHP < 8.3, "proc_get_status" only returns the correct exit status on the first call.
* Subsequent calls return -1 as the process is discarded. This workaround caches the first
* retrieved exit status for consistent results in later calls, mimicking PHP 8.3 behavior.
*/
if (version_compare(PHP_VERSION, '8.3.0', '<')) {
if (version_compare(\PHP_VERSION, '8.3.0', '<')) {
static $cachedExitCode = null;

if (is_null($cachedExitCode) && !$running && $this->processInformation['exitcode'] !== -1) {
if (null === $cachedExitCode && !$running && $this->processInformation['exitcode'] !== -1) {
$cachedExitCode = $this->processInformation['exitcode'];
}

if (!is_null($cachedExitCode) && !$running && $this->processInformation['exitcode'] === -1) {
if (null !== $cachedExitCode && !$running && $this->processInformation['exitcode'] === -1) {
$this->processInformation['exitcode'] = $cachedExitCode;
}
}
Expand Down
0