Skip to content

Commit

Permalink
Makes the daemon gracefully exit on TERM signal
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jan 28, 2021
1 parent 09eb01b commit 6159f3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion hasses.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void beforeExit(void)
void sigint_handler(int sig)
{
beforeExit();
toLog(0,"Received INT signal, Exiting...\n");
toLog(0,"Received INT/TERM signal, Exiting...\n");
exit(0);
}

Expand Down Expand Up @@ -242,6 +242,12 @@ void attach_signal_handler(void)
beforeExit();
exit(1);
}
if(sigaction(SIGTERM, &sa, NULL) == -1)
{
toLog(0,"Error, Cannot set signal handler: sigaction() failure. Exiting...\n");
beforeExit();
exit(1);
}
}

int create_open_fifo(const char *fifofile)
Expand Down
2 changes: 1 addition & 1 deletion hasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef HASSES_HASSES_H
#define HASSES_HASSES_H

#define VERSION "1.23"
#define VERSION "1.24"

/* The client timeout check interval in seconds */
#define CLIENT_CHK_TIME_INTERVAL 60
Expand Down

0 comments on commit 6159f3e

Please sign in to comment.