public function signal($signal)
    {
        // Log all signals sent to the daemon.
        $this->getLogger()->debug('Received signal: ' . $signal);

        // Let's make sure we have an application instance.
        if (!is_subclass_of($this, __CLASS__)) {
            $this->getLogger()->emergency('Cannot find the application instance.');

            throw new \RuntimeException('Cannot find the application instance.');
        }

        // @event onReceiveSignal

        switch ($signal) {
            case SIGINT:
            case SIGTERM:
                // Handle shutdown tasks
                if ($this->running && $this->isActive()) {
                    $this->shutdown();
                } else {
                    $this->close();
                }

                break;

            case SIGHUP:
                // Handle restart tasks
                if ($this->running && $this->isActive()) {
                    $this->shutdown(true);
                } else {
                    $this->close();
                }

                break;

            case SIGCHLD:
                // A child process has died
                while ($this->pcntlWait($signal, WNOHANG || WUNTRACED) > 0) {
                    usleep(1000);
                }

                break;

            case SIGCLD:
                while ($this->pcntlWait($signal, WNOHANG) > 0) {
                    $signal = $this->pcntlChildExitStatus($signal);
                }

                break;

            default:
                break;
        }
    }
public function signal($signal)
    {
        // Log all signals sent to the daemon.
        $this->getLogger()->debug('Received signal: ' . $signal);

        // Let's make sure we have an application instance.
        if (!is_subclass_of($this, __CLASS__)) {
            $this->getLogger()->emergency('Cannot find the application instance.');

            throw new \RuntimeException('Cannot find the application instance.');
        }

        // @event onReceiveSignal

        switch ($signal) {
            case SIGINT:
            case SIGTERM:
                // Handle shutdown tasks
                if ($this->running && $this->isActive()) {
                    $this->shutdown();
                } else {
                    $this->close();
                }

                break;

            case SIGHUP:
                // Handle restart tasks
                if ($this->running && $this->isActive()) {
                    $this->shutdown(true);
                } else {
                    $this->close();
                }

                break;

            case SIGCHLD:
                // A child process has died
                while ($this->pcntlWait($signal, WNOHANG || WUNTRACED) > 0) {
                    usleep(1000);
                }

                break;

            case SIGCLD:
                while ($this->pcntlWait($signal, WNOHANG) > 0) {
                    $signal = $this->pcntlChildExitStatus($signal);
                }

                break;

            default:
                break;
        }
    }
public function signal ( $ signal ) { // Log all signals sent to the daemon. $ this -> getLogger ( ) -> debug ( 'Received signal: ' . $ signal ) ; // Let's make sure we have an application instance. if ( ! is_subclass_of ( $ this , __CLASS__ ) ) { $ this -> getLogger ( ) -> emergency ( 'Cannot find the application instance.' ) ; throw new \ RuntimeException ( 'Cannot find the application instance.' ) ; } // @event onReceiveSignal switch ( $ signal ) { case SIGINT : case SIGTERM : // Handle shutdown tasks if ( $ this -> running && $ this -> isActive ( ) ) { $ this -> shutdown ( ) ; } else { $ this -> close ( ) ; } break ; case SIGHUP : // Handle restart tasks if ( $ this -> running && $ this -> isActive ( ) ) { $ this -> shutdown ( true ) ; } else { $ this -> close ( ) ; } break ; case SIGCHLD : // A child process has died while ( $ this -> pcntlWait ( $ signal , WNOHANG || WUNTRACED ) > 0 ) { usleep ( 1000 ) ; } break ; case SIGCLD : while ( $ this -> pcntlWait ( $ signal , WNOHANG ) > 0 ) { $ signal = $ this -> pcntlChildExitStatus ( $ signal ) ; } break ; default : break ; } }
Method to handle POSIX signals.

@param   integer $signal The received POSIX signal.

@return  void

@since   2.0
@see     pcntl_signal()
@throws  \RuntimeException
Method to handle POSIX signals .