mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
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:
1 parent
207c2f6c5f
commit
280b0b2bd5
1 file changed
+6
-6
@@ -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 {}; },
|
||||
|
||||
Reference in new issue
Block a user