You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Aside from setting a short timeout, I don't see any way of reading from multiple channels. Programs will often write to both stdout and stderr, and it'd be nice to be able to capture both. The channel and/or stream aren't Sync so threads can't be used, and there doesn't seem to be any way of blocking on multiple streams in order to multiplex them.
The text was updated successfully, but these errors were encountered:
Unfortunately it looks like this is actually a limitation of libssh2 itself. These methods in libssh2 aren't synchronized (e.g. no mutexes) so it's not safe to concurrently call the underlying libssh2_channel_read_ex function. I think the way libssh2 expects multiplexing cases like this to be handled is to set the sockets into nonblocking mode and then handle the errors via select. That definitely seems a little painful, but unfortunately I don't think there's much else that can be done in this regard :(.
Perhaps I can investigate a binding via mio using ssh2-rs to provide nonblocking support, but that may be a bit of aways off!
Thanks, fortunately, I think my use case either prints to stdout or stderr, and the prints to stderr won't overflow any buffers, so I can just read stderr after exhausting stdout.
At least rust made it obvious that it wasn't safe to use the Stream in another thread :-)
Aside from setting a short timeout, I don't see any way of reading from multiple channels. Programs will often write to both stdout and stderr, and it'd be nice to be able to capture both. The channel and/or stream aren't Sync so threads can't be used, and there doesn't seem to be any way of blocking on multiple streams in order to multiplex them.
The text was updated successfully, but these errors were encountered: