From 56217bc9a5dd1ab5849b7418f314f85158f3be4d Mon Sep 17 00:00:00 2001 From: Warren Date: Sat, 20 Jun 2026 16:11:58 +0800 Subject: [PATCH] Fix exit-status: save exit code in ALL 3 try_wait() paths (not just timeout) --- data/auth.sqlite | Bin 73728 -> 73728 bytes markbase-core/src/ssh_server/channel.rs | 8 ++++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/data/auth.sqlite b/data/auth.sqlite index ab9c3a45811899095ba6af861b47790151d69720..03a3b4f62cc9a598cc72d096d0d1eb45fd1dbbff 100644 GIT binary patch delta 295 zcmZoTz|wGlWr8$g|3n#Q#{P{7?J|tnlMhNMOy-ci!=}HbiK9Pv^D9|4Mj*Sfu0Ln; zH@QDd`dc=Ck$=uF`G%KSmMJ$sH#M)MsFM9HC$lJ1N@{LC`|HhL^gr+mykTYLWMY5I zz`z1#07dPwiu(We=W}8}0$iIJ3z!v{o!E;evma>YUQP~X7RD@~TBprx?nW>%JMr9| z%>JO6iRUg*I*@1b%QxJNPMcr82@_(Jne6a?6WCM#|MN4>+5Ux}@jpNB93%%Z005JG BU)lfw delta 256 zcmZoTz|wGlWr8$g*F+g-#;%PC?J|rRlMhNMOy-ci!=|{TiK9Pj^D9|4Mj*Sfu0M0~ zH@QDdic2bQqMn diff --git a/markbase-core/src/ssh_server/channel.rs b/markbase-core/src/ssh_server/channel.rs index 7513258..c753b09 100644 --- a/markbase-core/src/ssh_server/channel.rs +++ b/markbase-core/src/ssh_server/channel.rs @@ -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