Toni Moreno - 2013-01-10

El problema esta en que tenim implementada la execucio de comandes en mode "bloquejant" [stream_set_blocking($stream, true)] en ssh.inc

    protected function sshexec_cmd($cmd)
    {

            $this->debug("SSH: EXEC: CMD MODE $cmd over $this->cid;");

            //EXEC
            $stream=ssh2_exec($this->cid,$cmd);
            $errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
            stream_set_blocking($errorStream, true);
            stream_set_blocking($stream, true);
            //GET OUTPUT
            $this->output = stream_get_contents($stream);
            $this->output.= stream_get_contents($errorStream);
    }

La alternativa seria fer-ho en mode no bloquejant [stream_set_blocking($stream, false)] i fer pooling del stream

    protected function sshexec_cmd($cmd)
    {

            $this->debug("SSH: EXEC: CMD MODE $cmd over $this->cid;");

            //EXEC
            $stream=ssh2_exec($this->cid,$cmd);
            $errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
            stream_set_blocking($errorStream, false);
            stream_set_blocking($stream, false);
            //GET OUTPUT FROM POOLLING

            while($i<XXX) {
               echo stream_get_contents($stream);
               echo streem_get_contents($errorStream);
               usleep(500);
            }

    }

El problema del segon cas..no tenim certessa absoluta de quan acava la comanda..!!!! Potser hauriem de consultar als developers com ho fan ells per saber quan acaba..