Subject: problems on closing channel

problems on closing channel

From: Peter <325131514_at_qq.com>
Date: Fri, 13 Sep 2013 16:37:04 +0800

I am using no-blocking API
 libssh2_channel_exec(channel,cmd);
 while(1)
 {
        int nread = libssh2_channel_read(channel, buf, buflen);
        if(nread>0)
               handle the buf
        if(nread==LIBSSH2_ERROR_EAGAIN)
                waitsocket();
        if(stop)
            break;
 }
 while(libssh2_channel_close(channel)==LIBSSH2_ERROR_EAGAIN)
          waitsocket();
 libssh2_channel_free(channel);
 when cmd=ping 8.8.8.8, and running the cmd, make stop=true, libssh2_channel_close(channel) can close the channel successful.
 But when cmd=ping (the address cannot be pinged) or other commands which output nothing. and then I make stop=true, the program would hangs at libssh2_channel_close(channel), and it always return LIBSSH2_ERROR_EAGAIN, so I cannot close the channel and cannot stop the command too.
 So, How can I force close the channel or how can I stop the command runing in the remote host?
  
 Regrads,
 Peter

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