window: add wrapper for EPOLL_CLOEXEC

Android does not have EPOLL_CLOEXEC, so add a fallback.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
Pekka Paalanen
2012-05-30 15:53:43 +03:00
committed by Kristian Høgsberg
parent 200019c0c6
commit 647f2bfd2a
3 changed files with 22 additions and 1 deletions
+17
View File
@@ -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);
}
+3
View File
@@ -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 */