©
This document uses PHP Chinese website manual Release
(PECL event >= 1.2.6-beta)
Event::addSignal — Makes signal event pending
$timeout
] )Event::addSignal() is an alias of Event::add()
Example #1 Event::addSignal() example
<?php
class MyEventSignal {
private $base , $ev ;
public function __construct ( $base ) {
$this -> base = $base ;
$this -> ev = Event :: signal ( $base , SIGTERM , array( $this , 'eventSighandler' ));
$this -> ev -> addSignal ();
}
public function eventSighandler ( $no , $c ) {
echo "Caught signal $no \n" ;
$this -> base -> exit ();
}
}
$base = new EventBase ();
$c = new MyEventSignal ( $base );
$base -> loop ();
?>
以上例程的输出类似于:
Caught signal 15