From 954a712666ea3c10bfe1adcb665e159317b88964 Mon Sep 17 00:00:00 2001 From: dmiller Date: Sat, 11 Jul 2026 22:06:27 +0000 Subject: [PATCH] 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. --- ncat/ncat_listen.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ncat/ncat_listen.c b/ncat/ncat_listen.c index 67ec811e8..2064eaa42 100644 --- a/ncat/ncat_listen.c +++ b/ncat/ncat_listen.c @@ -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