[php-src] Issue #11871: proc_get_status exitcode is -1 after setting SIGCHLD
| From: | campbsb | Date: | Fri, 04 Aug 2023 08:14:19 +0000 |
| Subject: | [php-src] Issue #11871: proc_get_status exitcode is -1 after setting SIGCHLD | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245100@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11871
Author: campbsb
### Description
After setting SIGCHLD, proc_get_status() returns unreliable exitcode values
On both el7 PHP 8.1.21 and el8 PHP 8.2122, setting SIGCHLD to SIG_IGN results in proc_get_status
returning exitcode -1. See https://stackoverflow.com/questions/71354900/php-proc-get-status-exitcode-is-always-1-after-pcntl-fork
On el8 PHP 8.1.22, setting SIGCHLD to a signal handler results in proc_get_status returning exitcode
-1, but el7 PHP 8.1.21 works correctly.
```
#!/usr/bin/env php
<?php
function handleSIGCHLD($signo) {
}
//pcntl_signal(SIGCHLD, 'handleSIGCHLD');
pcntl_signal(SIGCHLD, SIG_IGN);
$proc = proc_open("/usr/bin/sleep 1", [['pipe', 'r'],
['pipe', 'w'], ['pipe', 'w']], $pipes);
do {
$status = proc_get_status($proc);
if (! $status['running'])
break;
usleep(300000);
} while (true);
echo "Exitcode: $status[exitcode]", PHP_EOL;
```
### PHP Version
PHP 8.1.21 and PHP 8.8.22
### Operating System
RHEL 8.8