Skip to content

Commit

Permalink
Merge pull request #628 from JacobBarthelmeh/debugging
Browse files Browse the repository at this point in the history
avoid zombie processes
  • Loading branch information
ejohnstown authored Dec 4, 2023
2 parents 76c6c99 + 47ce821 commit c5cb920
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions apps/wolfsshd/wolfsshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,10 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
exit(0); /* exit child process and close down SSH connection */
}

/* do not wait for status of child process, and signal that the child can
* be reaped to avoid zombie processes when running in the foreground */
signal(SIGCHLD, SIG_IGN);

if (wolfSSHD_AuthReducePermissionsUser(conn->auth, pPasswd->pw_uid,
pPasswd->pw_gid) != WS_SUCCESS) {
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Error setting user ID");
Expand Down Expand Up @@ -1730,6 +1734,11 @@ static int NewConnection(WOLFSSHD_CONNECTION* conn)
exit(0);
}
else {
/* do not wait for status of child process, and signal that the
child can be reaped to avoid zombie processes when running in
the foreground */
signal(SIGCHLD, SIG_IGN);

wolfSSH_Log(WS_LOG_INFO, "[SSHD] Spawned new process %d\n", pd);
WCLOSESOCKET(conn->fd);
}
Expand Down

0 comments on commit c5cb920

Please sign in to comment.