From: David VaĊĦek Date: Fri, 25 Aug 2023 10:49:04 +0000 (+0200) Subject: utils: allow a repeated signal X-Git-Tag: v3.4.dev~9^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ceedab026266ea4218c1ced42e9f6cee34f69931;p=thirdparty%2Fknot-dns.git utils: allow a repeated signal It can help when the running handler gets stuck and the user needs to terminate the utility anyway. --- diff --git a/src/utils/common/signal.c b/src/utils/common/signal.c index df95ba7945..b46e40d8eb 100644 --- a/src/utils/common/signal.c +++ b/src/utils/common/signal.c @@ -26,6 +26,12 @@ int SIGNAL_REPEAT = 1; static void signal_handler(int signum) { + // Allow a repeated signal during the handler run (in case + // the handler gets stuck). + sigset_t set; + (void)sigaddset(&set, signum); + (void)sigprocmask(SIG_UNBLOCK, &set, NULL); + if (--SIGNAL_REPEAT < 0) { abort(); }