mirror of
https://github.com/norohind/hans.git
synced 2025-04-14 21:50:33 +03:00
Clean exit on signal
This commit is contained in:
parent
363a9d765e
commit
736099944d
17
src/main.cpp
17
src/main.cpp
@ -35,6 +35,16 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
static void sig_term_handler(int)
|
||||
{
|
||||
syslog(LOG_INFO, "SIGTERM received");
|
||||
}
|
||||
|
||||
static void sig_int_handler(int)
|
||||
{
|
||||
syslog(LOG_INFO, "SIGINT received");
|
||||
}
|
||||
|
||||
void usage()
|
||||
{
|
||||
printf(
|
||||
@ -176,10 +186,12 @@ int main(int argc, char *argv[])
|
||||
if (!verbose)
|
||||
setlogmask(LOG_UPTO(LOG_INFO));
|
||||
|
||||
signal(SIGTERM, sig_term_handler);
|
||||
signal(SIGINT, sig_int_handler);
|
||||
|
||||
Worker *worker;
|
||||
try
|
||||
{
|
||||
Worker *worker;
|
||||
|
||||
if (isServer)
|
||||
{
|
||||
worker = new Server(mtu, device, password, network, answerPing, uid, gid, 5000);
|
||||
@ -213,6 +225,7 @@ int main(int argc, char *argv[])
|
||||
catch (Exception e)
|
||||
{
|
||||
syslog(LOG_ERR, "%s", e.errorMessage());
|
||||
delete worker;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user