+/* Callbacks for polling the event pipe in the GLib event loop */
+static GPollFD fdevents_pfd;
+/* Called before entering the poll() */
+static gboolean fdevents_prepare(GSource *source, gint *timeout) {
+ /* No timeout for poll() */
+ *timeout = -1;
+ return FALSE;
+}
+/* Check to see whether a handled event has happened */
+static gboolean fdevents_check(GSource *source) {
+ return !!(fdevents_pfd.revents & G_IO_IN);
+}
+/* Read the event from the pipe and handle it */
+static gboolean fdevents_dispatch(GSource *source,
+ GSourceFunc callback, gpointer user_data) {
+ int eventnum;
+
+ if (read(eventpipe[0], &eventnum, sizeof eventnum) == (sizeof eventnum)) {
+ /* Handle the event passed to us */
+ switch (eventnum) {
+ /* SIGHUP received -- reread config file */
+ case SIGHUP:
+ read_config();
+ break;
+ default:
+ return FALSE;
+ }
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+static GSourceFuncs fdevents_funcs = {
+ .prepare = fdevents_prepare,
+ .check = fdevents_check,
+ .dispatch = fdevents_dispatch,
+ .finalize = NULL,
+};
+
+
+static void read_config(void) {