From 6ce5dd5e6155d9b8810538972121e42bf0da09bd Mon Sep 17 00:00:00 2001
From: Dan Egnor <egnor@ofb.net>
Date: Fri, 22 Mar 2002 03:05:25 +0000
Subject: [PATCH] Rearrange deck chairs

---
 configure.in | 2 +-
 signal.c     | 8 +++++++-
 sys.c        | 6 +++++-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/configure.in b/configure.in
index 5790a39..60293b2 100644
--- a/configure.in
+++ b/configure.in
@@ -24,7 +24,7 @@ case "$host" in
     ;;
 esac
 
-AC_CHECK_HEADERS(poll.h sys/select.h)
+AC_CHECK_HEADERS(poll.h sys/select.h sys/socket.h)
 
 AC_CHECK_LIB(adns,adns_init,[
   ADNS_LIBS="-ladns"
diff --git a/signal.c b/signal.c
index 5620a20..9f2343e 100644
--- a/signal.c
+++ b/signal.c
@@ -9,6 +9,7 @@
 #include <assert.h>
 #include <signal.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 #define MAGIC 5131
 
@@ -21,7 +22,7 @@ struct sig_handler {
 struct sig_signal {
 	struct sig_handler *list,*ptr;
 	struct sigaction old;
-	int active;
+	volatile sig_atomic_t active;
 };
 
 struct oop_adapter_signal {
@@ -195,6 +196,11 @@ oop_adapter_signal *oop_signal_new(oop_source *source) {
 		return NULL;
 	}
 
+        fcntl(s->pipefd[0],F_SETFD,FD_CLOEXEC);
+        fcntl(s->pipefd[1],F_SETFD,FD_CLOEXEC);
+        fcntl(s->pipefd[0],F_SETFL,O_NONBLOCK);
+        fcntl(s->pipefd[1],F_SETFL,O_NONBLOCK);
+
 	s->oop.on_fd = sig_on_fd;
 	s->oop.cancel_fd = sig_cancel_fd;
 	s->oop.on_time = sig_on_time;
diff --git a/sys.c b/sys.c
index f33a631..2f6bbb0 100644
--- a/sys.c
+++ b/sys.c
@@ -19,6 +19,10 @@
 #include <sys/select.h>
 #endif
 
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
 #define MAGIC 0x9643
 
 struct sys_time {
@@ -37,7 +41,7 @@ struct sys_signal_handler {
 struct sys_signal {
 	struct sys_signal_handler *list,*ptr;
 	struct sigaction old;
-	int active;
+	volatile sig_atomic_t active;
 };
 
 struct sys_file_handler {
-- 
GitLab