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:
Maksim Yevmenkin 2006-03-14 19:29:40 +00:00
parent 07b4d1cc39
commit 31ae0caec1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=156713

View file

@ -49,13 +49,15 @@ 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);
/*
* bthidd
*/
static int done = 0; /* are we done? */
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
*/