1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-10-27 18:20:13 -04:00

Block SIGINT, SIGTERM and SIGQUIT when in the signal handler

This commit is contained in:
John Zaitseff 2011-08-10 00:30:38 +10:00
parent 040e1a5ad6
commit 738ffcd69a

View File

@ -154,9 +154,12 @@ void init_screen (void)
// Initialise signal handlers // Initialise signal handlers
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = sigterm_handler; sa.sa_handler = sigterm_handler;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sigaddset(&sa.sa_mask, SIGINT);
sigaddset(&sa.sa_mask, SIGTERM);
sigaddset(&sa.sa_mask, SIGQUIT);
if (sigaction(SIGINT, &sa, NULL) == -1) { if (sigaction(SIGINT, &sa, NULL) == -1) {
errno_exit("sigaction(SIGINT)"); errno_exit("sigaction(SIGINT)");
@ -330,9 +333,9 @@ void sigterm_handler (int sig)
endwin(); endwin();
// Reraise the same signal, using the system-default handler // Reraise the same signal, using the system-default handler
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = SIG_DFL; sa.sa_handler = SIG_DFL;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sigaction(sig, &sa, NULL); sigaction(sig, &sa, NULL);
raise(sig); raise(sig);