diff options
| author | David Walker <dave@mudsite.com> | 2016-12-19 14:29:18 -0700 |
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2016-12-29 21:18:22 +0100 |
| commit | b09c2f899ebc14029d0936d770cced10b607f84b (patch) | |
| tree | e993d4f6b21c1d929bc14278c8a9e9452cceb7e1 /ext/pcntl | |
| parent | 7746ed9d5f2e195e26b6e468c303dc1e86af12af (diff) | |
| download | php-git-b09c2f899ebc14029d0936d770cced10b607f84b.tar.gz | |
Fixed bug #73783
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.
Diffstat (limited to 'ext/pcntl')
| -rw-r--r-- | ext/pcntl/tests/bug73783.phpt | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ext/pcntl/tests/bug73783.phpt b/ext/pcntl/tests/bug73783.phpt new file mode 100644 index 0000000000..beacdf6b8d --- /dev/null +++ b/ext/pcntl/tests/bug73783.phpt @@ -0,0 +1,28 @@ +--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 |
