www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: libssh2_channel_close/libssh2_channel_free hangs if you execute long-running command

Re: libssh2_channel_close/libssh2_channel_free hangs if you execute long-running command

From: Henrik Nordström <henrik_at_henriknordstrom.net>
Date: Sat, 15 Oct 2011 01:40:16 +0200

fre 2011-10-14 klockan 16:00 -0700 skrev Pavel Strashkin:
> OK, after really long investigation i've found the reason why it
> hangs. Now i'm not sure either client or server is the reason of that.
> The following stuff is happening. When "close" is received by server,
> it closes pipes (stdout, ...) connected to the program and waits for
> program termination. When pipe closed from one side, other side will
> get SIGPIPE signal when attempting to write, but...before each write
> it waits for [interval] seconds so that's why it hangs for the same
> time. I'm talking about iostat, mpstat. I think it should be
> documented very clearly in libssh2 docs for further users. The same
> happens for "eof" request.

Who says close should not be initiated by client to immediately
terminate the channel & process?

Sure, it's not the normal way, but there is nothing wrong with it.

How the server shuts down the running program when receiving a CLOSE
request is outside specifications, but I would not expect it to wait for
the program to exit before responding to the CLOSE requests. But
implementations are free to wait if they insist. It's however not
guaranteed it's possible to send a kill signal after the CLOSE so
waiting like that puts the client in a little odd situation if the
program never exits.

EOF should differ significantly as it's unidirectional. Sending EOF
should only close stdin to the program, stdout should still be connected
to the channel.

Regards
Henrik

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-10-15

the libssh2 team