xref: /PHP-7.1/ext/pcntl/tests/async_signals.phpt (revision 7af945e2)
1--TEST--
2Asynchronous signal handling through VM interrupts
3--SKIPIF--
4<?php
5	if (!extension_loaded("pcntl")) print "skip";
6	elseif (!function_exists("pcntl_signal")) print "skip pcntl_signal() not available";
7	elseif (!function_exists("posix_kill")) print "skip posix_kill() not available";
8	elseif (!function_exists("posix_getpid")) print "skip posix_getpid() not available";
9?>
10--FILE--
11<?php
12pcntl_async_signals(1);
13
14pcntl_signal(SIGTERM, function ($signo) { echo "Signal handler called!\n"; });
15
16echo "Start!\n";
17posix_kill(posix_getpid(), SIGTERM);
18$i = 0; // dummy
19echo "Done!\n";
20
21?>
22--EXPECTF--
23Start!
24Signal handler called!
25Done!
26