Fix exit-status: save exit code in ALL 3 try_wait() paths (not just timeout)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled

This commit is contained in:
Warren
2026-06-20 16:11:58 +08:00
parent 87f5afb9d3
commit 56217bc9a5
2 changed files with 6 additions and 2 deletions

Binary file not shown.

View File

@@ -1629,8 +1629,10 @@ impl ChannelManager {
if let Some(exec_process) = &mut channel.exec_process {
match exec_process.child.try_wait() {
Ok(Some(status)) => {
info!("Child exited after max iterations (status: {:?})", status);
let exit_code = status.code().unwrap_or(-1) as u32;
info!("Child exited after max iterations (exit_status: {}, status: {:?})", exit_code, status);
child_exited = true;
channel.exit_status = Some(exit_code);
// 读取剩余stdout
if let Some(stdout) = &mut exec_process.stdout {
@@ -1804,8 +1806,10 @@ impl ChannelManager {
// ⭐⭐⭐⭐⭐ 立即检查child是否exited
match exec_process.child.try_wait() {
Ok(Some(status)) => {
info!("⭐⭐⭐⭐⭐ Child exited after stdout/stderr EOF (status: {:?})", status);
let exit_code = status.code().unwrap_or(-1) as u32;
info!("⭐⭐⭐⭐⭐ Child exited after stdout/stderr EOF (exit_status: {}, status: {:?})", exit_code, status);
child_exited = true;
channel.exit_status = Some(exit_code);
// ⭐⭐⭐⭐⭐ 关键立即返回child_exited标志
// server.rs会发送SSH_MSG_CHANNEL_EOF + CLOSE