Skip to content

Commit

Permalink
[fix] Fix signal handling
Browse files Browse the repository at this point in the history
Do not reset signal handlers to `SIG_IGN` if they were set to it
previously.

Explicitly exit when a signal is received.
  • Loading branch information
mmalecki committed Jul 3, 2013
1 parent 3a7fc2e commit fa40a2a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/aeternum.c
Expand Up @@ -115,6 +115,7 @@ void handle_signal(int signal_status) {
if (opts.pidname) {
cleanup_pid_file(opts.pidname);
}
exit(0);
}

int stdio_redirect(char *dest, int fd) {
Expand Down Expand Up @@ -155,10 +156,9 @@ int main(int argc, char *argv[]) {
saneopt_t* opt;
char** args;

if (signal (SIGINT, handle_signal) == SIG_IGN)
signal (SIGINT, SIG_IGN);
if (signal (SIGHUP, handle_signal) == SIG_IGN)
signal (SIGHUP, SIG_IGN);
signal(SIGHUP, SIG_IGN);
signal(SIGINT, handle_signal);
signal(SIGTERM, handle_signal);

loop = uv_default_loop();

Expand Down

0 comments on commit fa40a2a

Please sign in to comment.