This repository has been archived on 2018-04-01. You can view files and clone it, but cannot push or open issues or pull requests.
php-asio/tests/03-signal.phpt

24 lines
504 B
PHP

--TEST--
Test for `Signal`.
--FILE--
<?php
$service = new Asio\Service;
$signal = $service->addSignal();
if ($ec = $signal->add(SIGINT))
die('Signal::add() failed. '.posix_strerror($ec));
$signal->wait(function ($signal, $sig_num, $ec) use ($service) {
if ($ec) {
echo 'Error on Timer::wait(). ', posix_strerror($ec);
return;
}
echo $sig_num;
});
$service->post(function () {
if (!posix_kill(posix_getpid(), SIGINT))
exit;
});
$service->run();
?>
--EXPECT--
2