summaryrefslogtreecommitdiff
path: root/ext/pcntl/tests
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2016-07-06 13:11:47 +0300
committerDmitry Stogov <dmitry@zend.com>2016-07-06 13:11:47 +0300
commitc03ccfe78d6b13cab9546efb616a42a8f3e8a4e0 (patch)
treee5794025fce38e1e5040bf6240284bb258527ce9 /ext/pcntl/tests
parente2e72e1f5c2fb32a2e7166a8acdf18957decaeda (diff)
downloadphp-git-c03ccfe78d6b13cab9546efb616a42a8f3e8a4e0.tar.gz
Asynchronous signal handling without TICKs.
Squashed commit of the following: commit eda931df181060e202d2c664b4cba73a24afc6a1 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 bfbf7dd7c2389ebada6c4464b276d9fa33fcfb60 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jun 24 12:25:31 2016 +0300 Asynchronous signal handling without TICKs.
Diffstat (limited to 'ext/pcntl/tests')
-rw-r--r--ext/pcntl/tests/async_signals.phpt25
1 files changed, 25 insertions, 0 deletions
diff --git a/ext/pcntl/tests/async_signals.phpt b/ext/pcntl/tests/async_signals.phpt
new file mode 100644
index 0000000000..b650606df3
--- /dev/null
+++ b/ext/pcntl/tests/async_signals.phpt
@@ -0,0 +1,25 @@
+--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!