Check return value of sigaction(), even though it should never fail.

This commit is contained in:
Todd C. Miller
2014-09-04 10:13:26 -06:00
parent 111136dc8b
commit 328c563791
3 changed files with 90 additions and 41 deletions

View File

@@ -72,8 +72,10 @@ save_signals(void)
struct signal_state *ss;
debug_decl(save_signals, SUDO_DEBUG_MAIN)
for (ss = saved_signals; ss->signo != -1; ss++)
sigaction(ss->signo, NULL, &ss->sa);
for (ss = saved_signals; ss->signo != -1; ss++) {
if (sigaction(ss->signo, NULL, &ss->sa) != 0)
sudo_warn(U_("unable to save handler for signal %d"), ss->signo);
}
debug_return;
}
@@ -88,8 +90,12 @@ restore_signals(void)
debug_decl(restore_signals, SUDO_DEBUG_MAIN)
for (ss = saved_signals; ss->signo != -1; ss++) {
if (ss->restore)
sigaction(ss->signo, &ss->sa, NULL);
if (ss->restore) {
if (sigaction(ss->signo, &ss->sa, NULL) != 0) {
sudo_warn(U_("unable to restore handler for signal %d"),
ss->signo);
}
}
}
debug_return;
@@ -145,8 +151,12 @@ init_signals(void)
/* Don't install these until exec time. */
break;
default:
if (ss->sa.sa_handler != SIG_IGN)
sigaction(ss->signo, &sa, NULL);
if (ss->sa.sa_handler != SIG_IGN) {
if (sigaction(ss->signo, &sa, NULL) != 0) {
sudo_warn(U_("unable to set handler for signal %d"),
ss->signo);
}
}
break;
}
}