Subject: Re: problems on closing channel

Re: problems on closing channel

From: Peter <325131514_at_qq.com>
Date: Fri, 13 Sep 2013 17:31:54 +0800

Oh, so that' why I failed to close the channel, thank you.
 In fact, I have thought another ways, but it failed too. I think you can help me.
 There are two threads using the same session, thread1 open a channel and then run command(such as ping) as I mentioned above. And thread2 open another channel run command such as "killall ping" to terminate the command. The situation is when the thread1 in running, try to start thread2, when then channel2 is opened, thread1 run into error on reading stdout or stderr, and the program failed
 So,
 Two channels from the same session running at the same time is Ok or not? If it's ok, what are the problems on my program?
  
 Thanks.




------------------ Original ------------------
From: "Peter Stuge";
Date: 2013年9月13日(星期五) 下午5:08
To: "libssh2-devel";
Subject: Re: problems on closing channel



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
.

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