summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/os-compatibility.c17
-rw-r--r--shared/os-compatibility.h3
2 files changed, 20 insertions, 0 deletions
diff --git a/shared/os-compatibility.c b/shared/os-compatibility.c
index b79aa1f..3c065e8 100644
--- a/shared/os-compatibility.c
+++ b/shared/os-compatibility.c
@@ -25,6 +25,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
+#include <sys/epoll.h>
#include "os-compatibility.h"
@@ -76,3 +77,19 @@ os_socketpair_cloexec(int domain, int type, int protocol, int *sv)
return -1;
}
+int
+os_epoll_create_cloexec(void)
+{
+ int fd;
+
+#ifdef EPOLL_CLOEXEC
+ fd = epoll_create1(EPOLL_CLOEXEC);
+ if (fd >= 0)
+ return fd;
+ if (errno != EINVAL)
+ return -1;
+#endif
+
+ fd = epoll_create(1);
+ return set_cloexec_or_close(fd);
+}
diff --git a/shared/os-compatibility.h b/shared/os-compatibility.h
index ca753b6..6ada7b6 100644
--- a/shared/os-compatibility.h
+++ b/shared/os-compatibility.h
@@ -36,4 +36,7 @@ backtrace(void **buffer, int size)
int
os_socketpair_cloexec(int domain, int type, int protocol, int *sv);
+int
+os_epoll_create_cloexec(void);
+
#endif /* OS_COMPATIBILITY_H */