示例#1
0
 /**
  * Completes the process (soft)
  */
 public static function stop()
 {
     self::$stopFlag = 1;
 }
示例#2
0
 /**
  * PCNTL signals handler
  *
  * @param $signo
  * @param null $pid
  * @param null $status
  */
 static final function signalHandler($signo, $pid = null, $status = null)
 {
     switch ($signo) {
         case SIGINT:
         case SIGTERM:
             //shutdown
             self::$stopFlag = true;
             break;
         case SIGHUP:
             //restart, not implemented
             break;
         case SIGUSR1:
             //user signal, not implemented
             break;
         case SIGCHLD:
             if (!$pid) {
                 $pid = pcntl_waitpid(-1, $status, WNOHANG);
             }
             while ($pid > 0) {
                 if ($pid && isset(static::$currentJobs[$pid])) {
                     unset(static::$currentJobs[$pid]);
                 }
                 $pid = pcntl_waitpid(-1, $status, WNOHANG);
             }
             break;
     }
 }