Save and restore errno in sigchld_handler()

waitpid() can set errno, which might hide an error from the main thread
when running the signal handler.
This commit is contained in:
dmiller 2026-07-11 22:06:27 +00:00
parent 49a85f9c3c
commit 954a712666

View file

@ -173,8 +173,10 @@ static int get_conn_count(void)
#ifndef WIN32
static void sigchld_handler(int signum)
{
int saved_errno = errno;
while (waitpid(-1, NULL, WNOHANG) > 0)
decrease_conn_count();
errno = saved_errno;
}
#endif