library/TaskDaemon/TaskDaemon.php
public function getPid()
    {
        $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)) {
            fclose($fpPid);
            return (int)file_get_contents($pidFile);
        }

        flock($fpPid, LOCK_UN);
        fclose($fpPid);
        @unlink($pidFile);
        return false;
    }
public function getPid()
    {
        $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)) {
            fclose($fpPid);
            return (int)file_get_contents($pidFile);
        }

        flock($fpPid, LOCK_UN);
        fclose($fpPid);
        @unlink($pidFile);
        return false;
    }
public function getPid ( ) { $ 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 ) ) { fclose ( $ fpPid ) ; return ( int ) file_get_contents ( $ pidFile ) ; } flock ( $ fpPid , LOCK_UN ) ; fclose ( $ fpPid ) ; @ unlink ( $ pidFile ) ; return false ; }
Get daemon PID

@return integer|false    Returns false if there is no daemon running
Get daemon PID