1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2026-02-05 18:20:32 +03:00

Fix preserve errno in SIGCHLD signal handler

Signal handler may interrupt code that depends on errno, and waitpid()
may modify errno, therefore, errno must be saved and restored before
returning.
This commit is contained in:
synqa
2026-02-01 23:30:04 +09:00
parent e722f78608
commit 88af7986b4

View File

@ -2140,9 +2140,13 @@ void UnixMemoryFree(void *addr)
// SIGCHLD handler
void UnixSigChldHandler(int sig)
{
int old_errno = errno;
// Recall the zombie processes
while (waitpid(-1, NULL, WNOHANG) > 0);
signal(SIGCHLD, UnixSigChldHandler);
errno = old_errno;
}
// Disable core dump