mirror of
https://github.com/CloudNebulaProject/vm-manager.git
synced 2026-04-10 13:20:41 +00:00
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:
parent
9274f7c47e
commit
7f65305fb8
1 changed files with 5 additions and 8 deletions
|
|
@ -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);
|
detail: format!("exec '{cmd}': {e}"),
|
||||||
|
|
||||||
channel.exec(cmd).map_err(|e| {
|
|
||||||
sess.set_blocking(true);
|
|
||||||
VmError::SshFailed {
|
|
||||||
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];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue