SSHServer: Send the actual exit status of commands

We now report the actual value instead of simply returning 0/-1. We're
now using the conventional representation for signal-terminated
processes and return an exit-status of 128 + signal number.
This commit is contained in:
Lucas Chollet committed 2026-11-04 09:47:43 +01:00
1 parent 207c2f6c5f
commit 280b0b2bd5
1 file changed
+6 -6
+6 -6
View File
@@ -1087,15 +1087,15 @@ ErrorOr<void> SSHClient::manage_child_death()
for (auto& session : m_sessions) {
TRY(session->system.visit([&]<DerivedFrom<ChildManagingSystem> T>(T& system) -> ErrorOr<void> {
if (system.child_pid == result.pid) {
bool exited_with_code_0 = true;
if (WIFEXITED(result.status)) {
exited_with_code_0 &= WEXITSTATUS(result.status) == 0;
} else if (WIFSIGNALED(result.status)) {
exited_with_code_0 = false;
system.exit_status = WEXITSTATUS(result.status);
}else if (WIFSIGNALED(result.status)) {
system.exit_status = 128 + WTERMSIG(result.status);
}
else {
VERIFY_NOT_REACHED();
}
// FIXME: Send the actual exit status.
system.exit_status = exited_with_code_0 ? 0 : -1;
TRY(close_session_if_needed(*session));
}
return {}; },