Skip to content

Commit 6159f3e

Browse files
author
root
committed
Makes the daemon gracefully exit on TERM signal
1 parent 09eb01b commit 6159f3e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

hasses.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void beforeExit(void)
7777
void sigint_handler(int sig)
7878
{
7979
beforeExit();
80-
toLog(0,"Received INT signal, Exiting...\n");
80+
toLog(0,"Received INT/TERM signal, Exiting...\n");
8181
exit(0);
8282
}
8383

@@ -242,6 +242,12 @@ void attach_signal_handler(void)
242242
beforeExit();
243243
exit(1);
244244
}
245+
if(sigaction(SIGTERM, &sa, NULL) == -1)
246+
{
247+
toLog(0,"Error, Cannot set signal handler: sigaction() failure. Exiting...\n");
248+
beforeExit();
249+
exit(1);
250+
}
245251
}
246252

247253
int create_open_fifo(const char *fifofile)

hasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#ifndef HASSES_HASSES_H
66
#define HASSES_HASSES_H
77

8-
#define VERSION "1.23"
8+
#define VERSION "1.24"
99

1010
/* The client timeout check interval in seconds */
1111
#define CLIENT_CHK_TIME_INTERVAL 60

0 commit comments

Comments
 (0)