|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-03-06 20:29 UTC] ionut dot dumitru at webland dot ro
Description: ------------ after ssh2_shell($this->ssh_connection,"vt102")) i'm issuing command and reading back from a server. after a while i kill the shell process id from the remote server. my script is being ran from the console as: php script.php when the session is killed from the other side, as soon as i try to read/write from that shell the terminal starts outputing a sort of error message which says: return rc = -1 there are 2 different behaviours which makes it really weired: when i use fread it echoes each time the script tries to read from the dead shell. when i use stream_get_contents, that error output starts flooding my console with very high speed as soon as I kill the session from the remote server. it doesn't even wait for a stream_get_contents call after the session is killed. I assume it binds it somehow from the previous system reads and makes me think it's an underlying layer that generates this. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 07:00:01 2025 UTC |
I was able to reproduce this bug with the script below: --- $stream = ssh2_shell($connection, "vt102"); stream_set_blocking($stream, true); fwrite($stream, "ls -1\n"); while (!feof($stream)) { $data = fread($stream, 4096); echo $data; } --- Then kill -9 the sshd process for the connection, the parent of the shell process. It appeared for reads from the libssh2 library that returned an error situation, the error was suppressed, expecting that the libssh2 eof check for a channel would return true. That was not the case in this situation. An error on read now sets eof on the stream. Also shows a warning with the errormessage returned by libssh2 This bug is fixed in SVN. It fixed my test case, but please test if this solved your problem.