private function isProcessRunning($pid)
    {
        $state = array();
        exec(sprintf('ps -o pid %d', $pid), $state);

        // remove alignment spaces from PIDs
        $state = array_map('trim', $state);

        /*
         * ps will return at least one row, the column labels.
         * If the process is running ps will return a second row with its status.
         *
         * check if pid is in that list to work even if some systems ignore the pid filter parameter
         */
        return 1 < count($state) && in_array($pid, $state);
    }