php-src/ext/pcntl/tests/async_signals.phpt
Dmitry Stogov c03ccfe78d Asynchronous signal handling without TICKs.
Squashed commit of the following:

commit eda931df18
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jul 6 10:53:30 2016 +0300

    Replace pcntl.async_signals INI direcrive with pcntl_async_signals() function.

commit bfbf7dd7c2
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Jun 24 12:25:31 2016 +0300

    Asynchronous signal handling without TICKs.
2016-07-06 13:11:47 +03:00

25 lines
641 B
PHP

--TEST--
Asynchronous signal handling through VM interrupts
--SKIPIF--
<?php
if (!extension_loaded("pcntl")) print "skip";
elseif (!function_exists("pcntl_signal")) print "skip pcntl_signal() not available";
elseif (!function_exists("posix_kill")) print "skip posix_kill() not available";
elseif (!function_exists("posix_getpid")) print "skip posix_getpid() not available";
?>
--FILE--
<?php
pcntl_async_signals(1);
pcntl_signal(SIGTERM, function ($signo) { echo "Signal handler called!\n"; });
echo "Start!\n";
posix_kill(posix_getpid(), SIGTERM);
$i = 0; // dummy
echo "Done!\n";
?>
--EXPECTF--
Start!
Signal handler called!
Done!