protected function procOpen($cmd, Result $result)
    {
        $spec = array(
            0 => array("pipe", "r"), // STDIN
            1 => array("pipe", "w"), // STDOUT
            2 => array("pipe", "w"),  // STDERR
        );

        $pipes = array();

        $process = proc_open($cmd, $spec, $pipes, $this->cwd);

        if (is_resource($process)) {
            $result->setStdIn($this->stdIn);

            if ($this->stdIn !== null) {
                fwrite($pipes[0], $this->stdIn);
            }
            fclose($pipes[0]);

            $result->setStdOut(trim(stream_get_contents($pipes[1])));
            fclose($pipes[1]);

            $result->setStdErr(trim(stream_get_contents($pipes[2])));
            fclose($pipes[2]);

            $result->setExitCode(proc_close($process));

            $lLine = explode(PHP_EOL, $result->getStdOut());
            $result->setLastLine(trim(array_pop($lLine)));
        }

        return $result;
    }
protected function procOpen($cmd, Result $result)
    {
        $spec = array(
            0 => array("pipe", "r"), // STDIN
            1 => array("pipe", "w"), // STDOUT
            2 => array("pipe", "w"),  // STDERR
        );

        $pipes = array();

        $process = proc_open($cmd, $spec, $pipes, $this->cwd);

        if (is_resource($process)) {
            $result->setStdIn($this->stdIn);

            if ($this->stdIn !== null) {
                fwrite($pipes[0], $this->stdIn);
            }
            fclose($pipes[0]);

            $result->setStdOut(trim(stream_get_contents($pipes[1])));
            fclose($pipes[1]);

            $result->setStdErr(trim(stream_get_contents($pipes[2])));
            fclose($pipes[2]);

            $result->setExitCode(proc_close($process));

            $lLine = explode(PHP_EOL, $result->getStdOut());
            $result->setLastLine(trim(array_pop($lLine)));
        }

        return $result;
    }
protected function procOpen ( $ cmd , Result $ result ) { $ spec = array ( 0 => array ( "pipe" , "r" ) , // STDIN 1 => array ( "pipe" , "w" ) , // STDOUT 2 => array ( "pipe" , "w" ) , // STDERR ) ; $ pipes = array ( ) ; $ process = proc_open ( $ cmd , $ spec , $ pipes , $ this -> cwd ) ; if ( is_resource ( $ process ) ) { $ result -> setStdIn ( $ this -> stdIn ) ; if ( $ this -> stdIn !== null ) { fwrite ( $ pipes [ 0 ] , $ this -> stdIn ) ; } fclose ( $ pipes [ 0 ] ) ; $ result -> setStdOut ( trim ( stream_get_contents ( $ pipes [ 1 ] ) ) ) ; fclose ( $ pipes [ 1 ] ) ; $ result -> setStdErr ( trim ( stream_get_contents ( $ pipes [ 2 ] ) ) ) ; fclose ( $ pipes [ 2 ] ) ; $ result -> setExitCode ( proc_close ( $ process ) ) ; $ lLine = explode ( PHP_EOL , $ result -> getStdOut ( ) ) ; $ result -> setLastLine ( trim ( array_pop ( $ lLine ) ) ) ; } return $ result ; }
Method to run the command using proc_open

@param  string $cmd    The command string
@param  Result $result A result object used to store the result of the command
@return Result The command's result
Method to run the command using proc_open