Skip to content

Commit

Permalink
improve unix/linux wait for child exit status
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobBarthelmeh committed Jan 23, 2024
1 parent 6e5a614 commit 39b6e26
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions apps/wolfsshd/wolfsshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1463,11 +1463,22 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
/* get return value of child process */
{
int waitStatus;
waitpid(-1, &waitStatus, WNOHANG);
if (wolfSSH_SetExitStatus(ssh, (word32)WEXITSTATUS(waitStatus)) !=

do {
rc = waitpid(childPid, &waitStatus, 0);
/* if the waitpid experinced an interupt then try again */
} while (rc < 0 && errno == EINTR);

if (rc < 0) {
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Issue waiting for childs exit "
"status");
}
else {
if (wolfSSH_SetExitStatus(ssh, (word32)WEXITSTATUS(waitStatus)) !=
WS_SUCCESS) {
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Issue sending childs exit "
"status");
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Issue setting childs exit "
"status");
}
}
}
(void)conn;
Expand Down

0 comments on commit 39b6e26

Please sign in to comment.