Skip to content

Commit

Permalink
linux: use O_CLOEXEC instead of EPOLL_CLOEXEC
Browse files Browse the repository at this point in the history
It was reported that EPOLL_CLOEXEC is not defined on Android API < 21,
a.k.a. Lollipop. Since EPOLL_CLOEXEC is an alias for O_CLOEXEC on all
architectures, we just use that instead.

Fixes: #2167
PR-URL: #2272
Refs: #2216
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
bnoordhuis committed Apr 23, 2019
1 parent 37042a5 commit ab58591
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/unix/linux-core.c
Expand Up @@ -85,10 +85,14 @@ static unsigned long read_cpufreq(unsigned int cpunum);
int uv__platform_loop_init(uv_loop_t* loop) {
int fd;

fd = epoll_create1(EPOLL_CLOEXEC);
/* It was reported that EPOLL_CLOEXEC is not defined on Android API < 21,
* a.k.a. Lollipop. Since EPOLL_CLOEXEC is an alias for O_CLOEXEC on all
* architectures, we just use that instead.
*/
fd = epoll_create1(O_CLOEXEC);

/* epoll_create1() can fail either because it's not implemented (old kernel)
* or because it doesn't understand the EPOLL_CLOEXEC flag.
* or because it doesn't understand the O_CLOEXEC flag.
*/
if (fd == -1 && (errno == ENOSYS || errno == EINVAL)) {
fd = epoll_create(256);
Expand Down

0 comments on commit ab58591

Please sign in to comment.