diff options
author | Arnaud Le Blanc <lbarnaud@php.net> | 2008-07-29 16:46:11 +0000 |
---|---|---|
committer | Arnaud Le Blanc <lbarnaud@php.net> | 2008-07-29 16:46:11 +0000 |
commit | 204fcbe5d3ffb4a9c1383e39f7549b8326801894 (patch) | |
tree | 06674159670abd5a6167d2be1bb22c4b0285e740 /ext/pcntl/tests | |
parent | b6cca302116e9c3e1f8ef5d77699c05b94226de7 (diff) | |
download | php-git-204fcbe5d3ffb4a9c1383e39f7549b8326801894.tar.gz |
MFH: Added pcntl_signal_dispatch()
[DOC] pcntl_signal_dispatch() allows to dispatch pending signals to registered
signal handler functions on-demand. This allows to use pcntl_signal() without
ticks.
Diffstat (limited to 'ext/pcntl/tests')
-rw-r--r-- | ext/pcntl/tests/pcntl_signal_dispatch.phpt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ext/pcntl/tests/pcntl_signal_dispatch.phpt b/ext/pcntl/tests/pcntl_signal_dispatch.phpt new file mode 100644 index 0000000000..82e0a78f15 --- /dev/null +++ b/ext/pcntl/tests/pcntl_signal_dispatch.phpt @@ -0,0 +1,26 @@ +--TEST-- +pcnt_signal_dispatch() +--SKIPIF-- +<?php + if (!extension_loaded("pcntl")) print "skip"; + if (!function_exists("pcntl_signal")) print "skip pcntl_signal() not available"; + if (!function_exists("pcntl_signal_dispatch")) print "skip pcntl_signal_dispatch() not available"; + if (!function_exists("posix_kill")) print "skip posix_kill() not available"; + if (!function_exists("posix_getpid")) print "skip posix_getpid() not available"; +?> +--FILE-- +<?php + +pcntl_signal(SIGTERM, function ($signo) { echo "Signal handler called!\n"; }); + +echo "Start!\n"; +posix_kill(posix_getpid(), SIGTERM); +$i = 0; // dummy +pcntl_signal_dispatch(); +echo "Done!\n"; + +?> +--EXPECTF-- +Start! +Signal handler called! +Done! |