Parfois, lorsque je lance ce code, j'obtiens un processus et un identifiant et parfois la commande s'exécute mais le retour de données reste vide? Est-ce que quelqu'un sait comment attraper le flux correctement?ssh2_exec rand retourne l'identifiant du processus?
/**
* Run command in background and returns the process id
*
* @param string $cmd
* @return int process id
*/
public function runBackground($cmd)
{
$cmd = $cmd." > /dev/null & echo $!";
if (!($stream = ssh2_exec($this->_connection, $cmd))) {
return "fail: unable to execute command\n";
} else {
// collect returning data from command
stream_set_blocking($stream, true);
$data = "";
while ($buf = fread($stream,4096)) {
$data .= $buf;
}
fclose($stream);
return (int)$data;
}
}
Un patch a été publié il y a 2 jours, voir mon montage ci-dessous. – netcoder