From 9c92c5b514181c9c9f2a25228bb6aed6a89f9782 Mon Sep 17 00:00:00 2001 From: Oliver Giles Date: Mon, 4 Dec 2017 20:31:23 +0200 Subject: [PATCH] don't leak file descriptors into runs --- src/laminar.cpp | 2 +- src/server.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/laminar.cpp b/src/laminar.cpp index 56df60a..212a0c3 100644 --- a/src/laminar.cpp +++ b/src/laminar.cpp @@ -370,7 +370,7 @@ void Laminar::run() { sigemptyset(&mask); sigaddset(&mask, SIGCHLD); sigprocmask(SIG_BLOCK, &mask, NULL); - int sigchld = signalfd(-1, &mask, 0); + int sigchld = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC); srv->addDescriptor(sigchld, [this](const char* buf, size_t sz){ struct signalfd_siginfo* siginfo = (struct signalfd_siginfo*) buf; // TODO: re-enable assertion when the cause for its triggering diff --git a/src/server.cpp b/src/server.cpp index 03295ac..d42848e 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -407,7 +407,7 @@ void Server::start() { // this eventfd is just to allow us to quit the server at some point // in the future by adding this event to the async loop. I couldn't see // a simpler way... - efd_quit = eventfd(0,0); + efd_quit = eventfd(0, EFD_CLOEXEC|EFD_NONBLOCK); kj::Promise quit = kj::evalLater([this](){ static uint64_t _; auto wakeEvent = ioContext.lowLevelProvider->wrapInputFd(efd_quit);