From ea072c9adba2359d834a85563a7d57479fd454de Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 11 Oct 2018 18:52:12 +0200 Subject: util.poll: Handle failed epoll FD creation --- util-src/poll.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'util-src') diff --git a/util-src/poll.c b/util-src/poll.c index 293c8c2b..d2d9dc03 100644 --- a/util-src/poll.c +++ b/util-src/poll.c @@ -386,8 +386,19 @@ int Lnew(lua_State *L) { /* Initialize state */ #ifdef USE_EPOLL - state->epoll_fd = epoll_create1(0); + state->epoll_fd = -1; state->processed = 0; + + int epoll_fd = epoll_create1(EPOLL_CLOEXEC); + + if(epoll_fd <= 0) { + lua_pushnil(L); + lua_pushstring(L, strerror(errno)); + lua_pushinteger(L, errno); + return 3; + } + + state->epoll_fd = epoll_fd; #else FD_ZERO(&state->wantread); FD_ZERO(&state->wantwrite); -- cgit v1.2.3