public static function isRunning($file)
    {
        if (!extension_loaded('posix')) {
            throw new \Exception('posix extension required');
        }

        if (!is_readable($file)) {
            return false;
        }

        if (($lock = @fopen($file, 'c+')) === false) {
            throw new \Exception('unable to open pid file ' . $file);
        }

        if (flock($lock, LOCK_EX | LOCK_NB)) {
            return false;
        } else {
            flock($lock, LOCK_UN);
            return true;
        }
    }
public static function isRunning($file)
    {
        if (!extension_loaded('posix')) {
            throw new \Exception('posix extension required');
        }

        if (!is_readable($file)) {
            return false;
        }

        if (($lock = @fopen($file, 'c+')) === false) {
            throw new \Exception('unable to open pid file ' . $file);
        }

        if (flock($lock, LOCK_EX | LOCK_NB)) {
            return false;
        } else {
            flock($lock, LOCK_UN);
            return true;
        }
    }
public static function isRunning ( $ file ) { if ( ! extension_loaded ( 'posix' ) ) { throw new \ Exception ( 'posix extension required' ) ; } if ( ! is_readable ( $ file ) ) { return false ; } if ( ( $ lock = @ fopen ( $ file , 'c+' ) ) === false ) { throw new \ Exception ( 'unable to open pid file ' . $ file ) ; } if ( flock ( $ lock , LOCK_EX | LOCK_NB ) ) { return false ; } else { flock ( $ lock , LOCK_UN ) ; return true ; } }
Checks whether a daemon process specified by its PID file is running.

@throws \Exception

@param string $file   Daemon PID file

@return bool True if the daemon is still running, false otherwise
Checks whether a daemon process specified by its PID file is running .