2014-08-06 22:01:40 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process signals are "watchable" events just like timers and stream IO
|
|
|
|
* availability. SignalReactor::onSignal() returns a unique watcher ID that
|
|
|
|
* may be disabled/enabled/cancelled like any other watcher.
|
|
|
|
*
|
|
|
|
* The available signal number constants vary by operating system, but you
|
|
|
|
* can see the possible signals in your PHP install with the following
|
|
|
|
* snippet:
|
|
|
|
*
|
|
|
|
* <?php
|
|
|
|
* // Any constant beginning with SIG* is an available signal
|
|
|
|
* print_r((new ReflectionClass('UV'))->getConstants());
|
|
|
|
*/
|
2014-12-26 18:29:51 +01:00
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
2014-08-06 22:01:40 +02:00
|
|
|
|
2014-09-23 04:38:32 +02:00
|
|
|
(new Amp\UvReactor)->run(function($reactor) {
|
2014-08-06 22:01:40 +02:00
|
|
|
// Let's tick off output once per second so we can see activity.
|
|
|
|
$reactor->repeat(function() {
|
|
|
|
echo "tick: ", date('c'), "\n";
|
|
|
|
}, $msInterval = 1000);
|
|
|
|
|
|
|
|
// What to do when a SIGINT signal is received
|
|
|
|
$reactor->onSignal(UV::SIGINT, function() {
|
|
|
|
echo "Caught SIGINT! exiting ...\n";
|
|
|
|
exit;
|
|
|
|
});
|
|
|
|
});
|