avoid zombie processes

pull/628/head
JacobBarthelmeh 2023-12-04 00:13:39 -07:00
parent 76c6c9974f
commit 47ce821b33
1 changed files with 9 additions and 0 deletions

View File

@ -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");
@ -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);
}