From 31ac200a374e101ddfb60fbef0591efee58b478a Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 2 May 2014 17:34:22 +0200 Subject: [PATCH] debug: add more debug message for signal handling Adding log_sys_debug for eventual logging of system errors. (Using debug level, since currently signal handling functions do not fail when any error is encoutered). --- lib/misc/lvm-signal.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/misc/lvm-signal.c b/lib/misc/lvm-signal.c index 679f089a3..8aeb19223 100644 --- a/lib/misc/lvm-signal.c +++ b/lib/misc/lvm-signal.c @@ -67,20 +67,26 @@ void sigint_allow(void) } /* Grab old sigaction for SIGINT: shall not fail. */ - sigaction(SIGINT, NULL, &handler); + if (sigaction(SIGINT, NULL, &handler)) + log_sys_debug("sigaction", "SIGINT"); + handler.sa_flags &= ~SA_RESTART; /* Clear restart flag */ handler.sa_handler = _catch_sigint; _handler_installed2 = 1; /* Override the signal handler: shall not fail. */ - sigaction(SIGINT, &handler, &_oldhandler2); + if (sigaction(SIGINT, &handler, &_oldhandler2)) + log_sys_debug("sigaction", "SIGINT"); /* Unmask SIGINT. Remember to mask it again on restore. */ - sigprocmask(0, NULL, &sigs); + if (sigprocmask(0, NULL, &sigs)) + log_sys_debug("sigprocmask", ""); + if ((_oldmasked = sigismember(&sigs, SIGINT))) { sigdelset(&sigs, SIGINT); - sigprocmask(SIG_SETMASK, &sigs, NULL); + if (sigprocmask(SIG_SETMASK, &sigs, NULL)) + log_sys_debug("sigprocmask", "SIG_SETMASK"); } } @@ -101,10 +107,12 @@ void sigint_restore(void) sigset_t sigs; sigprocmask(0, NULL, &sigs); sigaddset(&sigs, SIGINT); - sigprocmask(SIG_SETMASK, &sigs, NULL); + if (sigprocmask(SIG_SETMASK, &sigs, NULL)) + log_sys_debug("sigprocmask", "SIG_SETMASK"); } - sigaction(SIGINT, &_oldhandler2, NULL); + if (sigaction(SIGINT, &_oldhandler2, NULL)) + log_sys_debug("sigaction", "SIGINT restore"); } void block_signals(uint32_t flags __attribute__((unused)))