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:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user