Teach bthidd(8) to reload its config when SIGHUP is received.
Submitted by: Iain Hibbert < plunky at rya-online dot net > MFC after: 3 days
This commit is contained in:
parent
d36ace4c25
commit
f8eae18fea
@ -49,6 +49,7 @@ static int write_pid_file (char const *file);
|
||||
static int remove_pid_file (char const *file);
|
||||
static int elapsed (int tval);
|
||||
static void sighandler (int s);
|
||||
static void sighup (int s);
|
||||
static void usage (void);
|
||||
|
||||
/*
|
||||
@ -56,6 +57,7 @@ static void usage (void);
|
||||
*/
|
||||
|
||||
static int done = 0; /* are we done? */
|
||||
static int reload = 0; /* reload config file */
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
@ -137,13 +139,19 @@ main(int argc, char *argv[])
|
||||
sa.sa_handler = sighandler;
|
||||
|
||||
if (sigaction(SIGTERM, &sa, NULL) < 0 ||
|
||||
sigaction(SIGHUP, &sa, NULL) < 0 ||
|
||||
sigaction(SIGINT, &sa, NULL) < 0) {
|
||||
syslog(LOG_CRIT, "Could not install signal handlers. %s (%d)",
|
||||
strerror(errno), errno);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sa.sa_handler = sighup;
|
||||
if (sigaction(SIGHUP, &sa, NULL) < 0) {
|
||||
syslog(LOG_CRIT, "Could not install signal handlers. %s (%d)",
|
||||
strerror(errno), errno);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sa.sa_handler = SIG_IGN;
|
||||
if (sigaction(SIGPIPE, &sa, NULL) < 0) {
|
||||
syslog(LOG_CRIT, "Could not install signal handlers. %s (%d)",
|
||||
@ -169,6 +177,15 @@ main(int argc, char *argv[])
|
||||
|
||||
if (server_do(&srv) < 0)
|
||||
break;
|
||||
|
||||
if (reload) {
|
||||
if (write_hids_file() < 0 ||
|
||||
read_config_file() < 0 ||
|
||||
read_hids_file() < 0)
|
||||
break;
|
||||
|
||||
reload = 0;
|
||||
}
|
||||
}
|
||||
|
||||
server_shutdown(&srv);
|
||||
@ -241,7 +258,7 @@ elapsed(int tval)
|
||||
}
|
||||
|
||||
/*
|
||||
* Signal handler
|
||||
* Signal handlers
|
||||
*/
|
||||
|
||||
static void
|
||||
@ -251,6 +268,13 @@ sighandler(int s)
|
||||
s, ++ done);
|
||||
}
|
||||
|
||||
static void
|
||||
sighup(int s)
|
||||
{
|
||||
syslog(LOG_NOTICE, "Got SIGHUP: reload config");
|
||||
reload = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Display usage and exit
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user