mirror of https://github.com/oupson/FooTerm.git
Improve ssh reading and detect eof or error
This commit is contained in:
parent
d0f95935a9
commit
b0d9a18006
|
@ -157,13 +157,20 @@ namespace FooTerm {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
ssize_t size = 0;
|
||||||
var buffer = new uint8[1024];
|
var buffer = new uint8[1024];
|
||||||
var size = this.channel.read(buffer);
|
do {
|
||||||
debug("Got %zu from ssh", size);
|
size = this.channel.read(buffer);
|
||||||
|
if (size > 0) {
|
||||||
if (Posix.write(this.slave_pty, buffer, size) < 0) {
|
debug("Got %zd bytes from ssh", size);
|
||||||
throw GLib.IOError.from_errno(Posix.errno);
|
if (Posix.write(this.slave_pty, buffer, size) < 0) {
|
||||||
}
|
throw GLib.IOError.from_errno(Posix.errno);
|
||||||
|
}
|
||||||
|
} else if ((size == 0 && channel.eof() != 0) || (size < 0 && size != SSH2.Error.AGAIN)) {
|
||||||
|
warning("Channel is closed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} while(size != SSH2.Error.AGAIN);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch(Error e) {
|
} catch(Error e) {
|
||||||
|
|
Loading…
Reference in New Issue