|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58576 killing from the remote server throws erros
Submitted: 2009-03-06 20:29 UTC Modified: 2012-06-23 05:35 UTC
From: ionut dot dumitru at webland dot ro Assigned: langemeijer (profile)
Status: Closed Package: ssh2 (PECL)
PHP Version: 5.2.5 OS: fedora 9 32b
Private report: No CVE-ID: None
 [2009-03-06 20:29 UTC] ionut dot dumitru at webland dot ro
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-23 05:20 UTC]
Automatic comment from SVN on behalf of langemeijer
Log: Handle error values from reads and writes to a channel. Closes bug #58576
 [2012-06-23 05:35 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 
 [2012-06-23 05:35 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: langemeijer
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Nov 30 12:01:25 2023 UTC