From e6660486a3cbaddeacbfc9a102b9c59d58f3faa6 Mon Sep 17 00:00:00 2001 From: Hiroki Noda Date: Thu, 9 Apr 2020 21:36:19 +0900 Subject: [PATCH] Set close-on-exec flag for PipeFD --- source/eventcore/drivers/posix/pipes.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/eventcore/drivers/posix/pipes.d b/source/eventcore/drivers/posix/pipes.d index 2b7390c..f1c833d 100644 --- a/source/eventcore/drivers/posix/pipes.d +++ b/source/eventcore/drivers/posix/pipes.d @@ -28,7 +28,8 @@ final class PosixEventDriverPipes(Loop : PosixEventLoop) : EventDriverPipes { if (m_loop.m_fds[fd].common.refCount) // FD already in use? return PipeFD.invalid; - () @trusted { fcntl(system_fd, F_SETFL, fcntl(system_fd, F_GETFL) | O_NONBLOCK); } (); + // Suprisingly cannot use O_CLOEXEC here, so use FD_CLOEXEC instead. + () @trusted { fcntl(system_fd, F_SETFL, fcntl(system_fd, F_GETFL) | O_NONBLOCK | FD_CLOEXEC); } (); m_loop.initFD(fd, FDFlags.none, PipeSlot.init); m_loop.registerFD(fd, EventMask.read|EventMask.write|EventMask.status);