Subject: Re: problems on closing channel

Re: problems on closing channel

From: Peter Stuge <peter_at_stuge.se>
Date: Fri, 13 Sep 2013 11:08:17 +0200

Peter wrote:
> The command did not exit, and I want it to be exit, so I close the
> channel to end the command.

That does not work.

If you want to prematurely terminate a process on a UNIX-like system
you have to send it a SIGTERM or SIGKILL signal. There is an OpenSSH
extension to send signals via SSH but it has not been standardized.
This means that it may work on some servers but will not work on all.

libssh2 does not implement support for the OpenSSH extension. Feel
free to implement that and try it with your application. After
sending the signal to the remote process you should see it exit on
the remote side. Then you need to read all stdout and stderr data,
and finally you can close the channel.

> BTW, I also read stderr after stdout. The situation is the same.

If the remote process is still running you will not be able to close
the channel. You must know when the remote process has terminated by
communicating with it through the channel.

SSH is a communications protocol, not really a remote process
management protocol.

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2013-09-13