summaryrefslogtreecommitdiff
path: root/shared/os-compatibility.c
diff options
context:
space:
mode:
authorPekka Paalanen <ppaalanen@gmail.com>2012-05-30 15:53:43 +0300
committerKristian Høgsberg <krh@bitplanet.net>2012-05-31 13:53:51 -0400
commit647f2bfd2a9214e5bebb2290252d013ccbbb290c (patch)
tree7a3e771586b5dc8098ab6d4fccec49e5bbae0a1e /shared/os-compatibility.c
parent200019c0c66ec757353ffaaea8d9c98da37f26c8 (diff)
window: add wrapper for EPOLL_CLOEXEC
Android does not have EPOLL_CLOEXEC, so add a fallback. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Diffstat (limited to 'shared/os-compatibility.c')
-rw-r--r--shared/os-compatibility.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/shared/os-compatibility.c b/shared/os-compatibility.c
index b79aa1fe..3c065e81 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);
+}