+#ifdef USE_SELF_PIPE
+static void
+main_sigchld_handler(int x UNUSED)
+{
+ int old_errno = errno;
+ DBG("SIGCHLD received");
+ chld_received = 1;
+ ssize_t result;
+ while((result = write(sig_pipe_send, "c", 1)) == -1 && errno == EINTR);
+ if(result == -1 && errno != EAGAIN)
+ msg(L_SIGHANDLER|L_ERROR, "Could not write to self-pipe: %m");
+ errno = old_errno;
+}
+
+static int
+dummy_read_handler(struct main_file *mp)
+{
+ char buffer[1024];
+ ssize_t result = read(mp->fd, buffer, 1024);
+ if(result == -1 && errno != EAGAIN)
+ msg(L_ERROR, "Could not read from selfpipe: %m");
+ file_chg(mp);
+ return result == 1024;
+}
+
+static void
+pipe_configure(int fd)
+{
+ int flags;
+ if((flags = fcntl(fd, F_GETFL)) == -1 || fcntl(fd, F_SETFL, flags|O_NONBLOCK))
+ die("Could not set file descriptor %d to non-blocking: %m", fd);
+ if((flags = fcntl(fd, F_GETFD)) == -1 || fcntl(fd, F_SETFD, flags|O_CLOEXEC))
+ die("Could not set file descriptor %d to close-on-exec: %m", fd);
+}
+#else