Merge pull request #39 from kubo39/epoll-cloexec

Set EPOLL_CLOEXEC to prevent fd leakage for command executation
This commit is contained in:
Sönke Ludwig 2017-12-16 18:58:40 +01:00 committed by GitHub
commit c3fa500c3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,6 +18,9 @@ import core.sys.linux.epoll;
alias EpollEventDriver = PosixEventDriver!EpollEventLoop;
static if (!is(typeof(SOCK_CLOEXEC)))
enum SOCK_CLOEXEC = 0x80000;
final class EpollEventLoop : PosixEventLoop {
@safe: nothrow:
@ -28,7 +31,7 @@ final class EpollEventLoop : PosixEventLoop {
this()
{
m_epoll = () @trusted { return epoll_create1(0); } ();
m_epoll = () @trusted { return epoll_create1(SOCK_CLOEXEC); } ();
m_events.length = 100;
}