From 88af7986b4b143dba48fdb9c753bebc87ba5817f Mon Sep 17 00:00:00 2001 From: synqa Date: Sun, 1 Feb 2026 23:30:04 +0900 Subject: [PATCH] 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. --- src/Mayaqua/Unix.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Mayaqua/Unix.c b/src/Mayaqua/Unix.c index 0c3778df..84da9326 100644 --- a/src/Mayaqua/Unix.c +++ b/src/Mayaqua/Unix.c @@ -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