Skip to content

Commit

Permalink
Factor out duplicate signal handling code
Browse files Browse the repository at this point in the history
No options are set for SIGTERM, so we can use the simpler
signal handling interface and remove unnecessary structure initilization.

sigemptyset() is moved outside of the ifdef to prevent any potential
unused variable warning.

Closes #1637
  • Loading branch information
mattsta committed Aug 2, 2014
1 parent 734a943 commit 2af2c63
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/redis.c
Expand Up @@ -3420,17 +3420,12 @@ static void sigShutdownHandler(int sig) {

void setupSignalHandlers(void) {
struct sigaction act;

/* When the SA_SIGINFO flag is set in sa_flags then sa_sigaction is used.
* Otherwise, sa_handler is used. */
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
act.sa_handler = sigShutdownHandler;
sigaction(SIGTERM, &act, NULL);

signal(SIGTERM, sigShutdownHandler);
signal(SIGINT, sigShutdownHandler);

#ifdef HAVE_BACKTRACE
sigemptyset(&act.sa_mask);
act.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
act.sa_sigaction = sigsegvHandler;
sigaction(SIGSEGV, &act, NULL);
Expand Down

0 comments on commit 2af2c63

Please sign in to comment.