mirror of
https://github.com/php/php-src.git
synced 2026-04-29 11:13:36 +02:00
b09c2f899e
Bug #73783 raises an issue with signal handling when using SIG_IGN. With PHP7.1 ZEND_SIGNALS is defaulted to on, which will for all signals set the handler as zend_signal_handler_defer. This is problematic for syscalls like sleep(), which will only return when the requisite number of seconds have elapsed, or, a non-ignored signal is raised. In this case we want to SIG_IGN SIGCHLD, however, SIG_IGN is only stored in the SIGG(handlers) array, and the actual system level handler is defined. This prevents proper signal ignoring when requeted.
29 lines
533 B
PHP
29 lines
533 B
PHP
--TEST--
|
|
Bug #73783: (SIG_IGN needs to be set to prevent syscals from returning early)
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('pcntl')) die('skip pcntl extension not available');
|
|
elseif (!extension_loaded('posix')) die('skip posix extension not available');
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
pcntl_signal(SIGCHLD, SIG_IGN);
|
|
|
|
switch(pcntl_fork()) {
|
|
case 0:
|
|
exit;
|
|
break;
|
|
}
|
|
|
|
$before = microtime(true);
|
|
sleep(1);
|
|
|
|
if (microtime(true) - $before >= 0.8) {
|
|
echo "working\n";
|
|
} else {
|
|
echo "failed\n";
|
|
}
|
|
?>
|
|
--EXPECTF--
|
|
working
|