public function stop()
    {
        $options = static::getOptions();
        $debug = @$options['debug'] === true;

        $pidFile = $options['pid_file'];
        if (!$pidFile)
            throw new \Exception("No pid_file in the config");

        $fpPid = fopen($pidFile, "c");
        if (!$fpPid)
            throw new \Exception("Could not open " . $pidFile);

        if (flock($fpPid, LOCK_EX | LOCK_NB)) {
            flock($fpPid, LOCK_UN);
            fclose($fpPid);
            if ($debug)
                echo "==> Daemon not running" . PHP_EOL;
            return;
        }

        fclose($fpPid);
        $pid = (int)file_get_contents($pidFile);
        if ($debug)
            echo "==> Killing the daemon (PID $pid)..." . PHP_EOL;

        posix_kill($pid, SIGTERM);
        pcntl_waitpid($pid, $status);
    }
public function stop()
    {
        $options = static::getOptions();
        $debug = @$options['debug'] === true;

        $pidFile = $options['pid_file'];
        if (!$pidFile)
            throw new \Exception("No pid_file in the config");

        $fpPid = fopen($pidFile, "c");
        if (!$fpPid)
            throw new \Exception("Could not open " . $pidFile);

        if (flock($fpPid, LOCK_EX | LOCK_NB)) {
            flock($fpPid, LOCK_UN);
            fclose($fpPid);
            if ($debug)
                echo "==> Daemon not running" . PHP_EOL;
            return;
        }

        fclose($fpPid);
        $pid = (int)file_get_contents($pidFile);
        if ($debug)
            echo "==> Killing the daemon (PID $pid)..." . PHP_EOL;

        posix_kill($pid, SIGTERM);
        pcntl_waitpid($pid, $status);
    }
public function stop ( ) { $ options = static :: getOptions ( ) ; $ debug = @ $ options [ 'debug' ] === true ; $ pidFile = $ options [ 'pid_file' ] ; if ( ! $ pidFile ) throw new \ Exception ( "No pid_file in the config" ) ; $ fpPid = fopen ( $ pidFile , "c" ) ; if ( ! $ fpPid ) throw new \ Exception ( "Could not open " . $ pidFile ) ; if ( flock ( $ fpPid , LOCK_EX | LOCK_NB ) ) { flock ( $ fpPid , LOCK_UN ) ; fclose ( $ fpPid ) ; if ( $ debug ) echo "==> Daemon not running" . PHP_EOL ; return ; } fclose ( $ fpPid ) ; $ pid = ( int ) file_get_contents ( $ pidFile ) ; if ( $ debug ) echo "==> Killing the daemon (PID $pid)..." . PHP_EOL ; posix_kill ( $ pid , SIGTERM ) ; pcntl_waitpid ( $ pid , $ status ) ; }
Stop the daemon

@return TaskDaemon
Stop the daemon