Fix exec_streaming blocking: run channel.exec() before switching to non-blocking mode

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Till Wegmueller 2026-02-15 12:18:02 +01:00
parent 9274f7c47e
commit 7f65305fb8
No known key found for this signature in database

View file

@ -104,16 +104,13 @@ pub fn exec_streaming<W1: std::io::Write, W2: std::io::Write>(
detail: format!("channel session: {e}"), detail: format!("channel session: {e}"),
})?; })?;
// Non-blocking mode so we can interleave stdout and stderr reads channel.exec(cmd).map_err(|e| VmError::SshFailed {
sess.set_blocking(false);
channel.exec(cmd).map_err(|e| {
sess.set_blocking(true);
VmError::SshFailed {
detail: format!("exec '{cmd}': {e}"), detail: format!("exec '{cmd}': {e}"),
}
})?; })?;
// Switch to non-blocking after exec so we can interleave stdout and stderr reads
sess.set_blocking(false);
let mut stdout_buf = Vec::new(); let mut stdout_buf = Vec::new();
let mut stderr_buf = Vec::new(); let mut stderr_buf = Vec::new();
let mut buf = [0u8; 8192]; let mut buf = [0u8; 8192];