- while (waitpid(-1, NULL, WNOHANG) > 0)
- log_msg("Waited for a zombie\n");
+ while (waitpid(-1, NULL, WNOHANG) > 0);
+}
+
+/* Handle other signals in event loop by writing signal number to pipe */
+int eventpipe[2];
+static void handle_signal(int signalnum) {
+ write(eventpipe[1], &signalnum, sizeof signalnum);
+}
+
+/* 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);