diff options
Diffstat (limited to 'daemon/Monitor.cpp')
-rw-r--r-- | daemon/Monitor.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/daemon/Monitor.cpp b/daemon/Monitor.cpp index b34a15f..74f22ee 100644 --- a/daemon/Monitor.cpp +++ b/daemon/Monitor.cpp @@ -9,6 +9,7 @@ #include "Monitor.h" #include <errno.h> +#include <fcntl.h> #include <string.h> #include <unistd.h> @@ -31,12 +32,25 @@ void Monitor::close() { } bool Monitor::init() { +#ifdef EPOLL_CLOEXEC + mFd = epoll_create1(EPOLL_CLOEXEC); +#else mFd = epoll_create(16); +#endif if (mFd < 0) { logg->logMessage("%s(%s:%i): epoll_create1 failed", __FUNCTION__, __FILE__, __LINE__); return false; } +#ifndef EPOLL_CLOEXEC + int fdf = fcntl(mFd, F_GETFD); + if ((fdf == -1) || (fcntl(mFd, F_SETFD, fdf | FD_CLOEXEC) != 0)) { + logg->logMessage("%s(%s:%i): fcntl failed", __FUNCTION__, __FILE__, __LINE__); + ::close(mFd); + return -1; + } +#endif + return true; } |