summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authoremax <emax@FreeBSD.org>2006-03-14 19:29:40 +0000
committeremax <emax@FreeBSD.org>2006-03-14 19:29:40 +0000
commitf8eae18feaf7131fbf001929cb08fcab8c8ddfe0 (patch)
tree7e7f66b608ab1a050388be84266fc1b0e4f24048 /usr.sbin
parentd36ace4c2575daf2f4ecdff71cfe1dc0f1edd458 (diff)
downloadFreeBSD-src-f8eae18feaf7131fbf001929cb08fcab8c8ddfe0.zip
FreeBSD-src-f8eae18feaf7131fbf001929cb08fcab8c8ddfe0.tar.gz
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
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bluetooth/bthidd/bthidd.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/usr.sbin/bluetooth/bthidd/bthidd.c b/usr.sbin/bluetooth/bthidd/bthidd.c
index 7340a0c..a0f1463 100644
--- a/usr.sbin/bluetooth/bthidd/bthidd.c
+++ b/usr.sbin/bluetooth/bthidd/bthidd.c
@@ -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
*/
OpenPOWER on IntegriCloud