From 31d645bc1e45ae28dfea5d4bd9da78067a32f070 Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Mon, 28 Sep 2026 08:21:02 -0400 Subject: [PATCH] KWSys 2026-09-28 (9fb826eb) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 9fb826ebca7d73ea64a94b8e8ec86cc3b6841b1b (master). Upstream Shortlog ----------------- Michael Pratt (1): 2c678e28 Process: Continue to ignore hangups if SIGHUP is ignored --- ProcessUNIX.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ProcessUNIX.c b/ProcessUNIX.c index 3f1e0fa2a2..214bc305f6 100644 --- a/ProcessUNIX.c +++ b/ProcessUNIX.c @@ -2339,14 +2339,20 @@ static void kwsysProcessChildErrorExit(int errorPipe) } /* Restores all signal handlers to their default values. */ +/* However, preserve SIGHUP if ignored, e.g. using nohup. */ static void kwsysProcessRestoreDefaultSignalHandlers(void) { struct sigaction act; +#ifdef SIGHUP + sigaction(SIGHUP, 0, &act); + if (act.sa_handler != SIG_IGN) { + memset(&act, 0, sizeof(struct sigaction)); + act.sa_handler = SIG_DFL; + sigaction(SIGHUP, &act, 0); + } +#endif memset(&act, 0, sizeof(struct sigaction)); act.sa_handler = SIG_DFL; -#ifdef SIGHUP - sigaction(SIGHUP, &act, 0); -#endif #ifdef SIGINT sigaction(SIGINT, &act, 0); #endif