public function isRunning()
    {
        $running = false;

        if (function_exists('posix_getpgid')) {
            $running = false !== posix_getpgid($this->pid);
        } elseif (PHP_OS === 'WINNT') {
            $command = 'tasklist /fo csv /nh /fi '
                . escapeshellarg('PID eq ' . $this->pid);

            $result  = exec($command);
            $parts   = explode(',', $result);
            $running = (count($parts) > 1 && trim($parts[1], '"') == $this->pid);
        } else {
            $result  = exec('ps -p ' . escapeshellarg($this->pid) . ' -o pid=');
            $running = (trim($result) == $this->pid);
        }

        return $running;
    }
public function isRunning()
    {
        $running = false;

        if (function_exists('posix_getpgid')) {
            $running = false !== posix_getpgid($this->pid);
        } elseif (PHP_OS === 'WINNT') {
            $command = 'tasklist /fo csv /nh /fi '
                . escapeshellarg('PID eq ' . $this->pid);

            $result  = exec($command);
            $parts   = explode(',', $result);
            $running = (count($parts) > 1 && trim($parts[1], '"') == $this->pid);
        } else {
            $result  = exec('ps -p ' . escapeshellarg($this->pid) . ' -o pid=');
            $running = (trim($result) == $this->pid);
        }

        return $running;
    }
public function isRunning ( ) { $ running = false ; if ( function_exists ( 'posix_getpgid' ) ) { $ running = false !== posix_getpgid ( $ this -> pid ) ; } elseif ( PHP_OS === 'WINNT' ) { $ command = 'tasklist /fo csv /nh /fi ' . escapeshellarg ( 'PID eq ' . $ this -> pid ) ; $ result = exec ( $ command ) ; $ parts = explode ( ',' , $ result ) ; $ running = ( count ( $ parts ) > 1 && trim ( $ parts [ 1 ] , '"' ) == $ this -> pid ) ; } else { $ result = exec ( 'ps -p ' . escapeshellarg ( $ this -> pid ) . ' -o pid=' ) ; $ running = ( trim ( $ result ) == $ this -> pid ) ; } return $ running ; }
Checks if the process is running

If the <kbd>posix</kbd> extension is available, <kbd>posix_getpgid()</kbd>
is used. Otherwise <kbd>ps</kbd> is used on UNIX-like systems and
<kbd>tasklist</kbd> on Windows.

@return boolean true if the process is running, false if not.
Checks if the process is running