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 committed 2026-02-05 18:51:58 +09:00
1 parent e722f78608
commit 88af7986b4
1 file changed
+4
+4
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