php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ionut dot dumitru at webland dot ro
New email:
PHP Version: OS:

 

 [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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-23 05:20 UTC] langemeijer@php.net
Automatic comment from SVN on behalf of langemeijer
Revision: http://svn.php.net/viewvc/?view=revision&revision=326304
Log: Handle error values from reads and writes to a channel. Closes bug #58576
 [2012-06-23 05:35 UTC] langemeijer@php.net
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.
 [2012-06-23 05:35 UTC] langemeijer@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: langemeijer
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 19:01:30 2024 UTC