From 0906e8f7b0c1dcc88930a6abe53612c11216aa0f Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Wed, 3 Dec 2014 23:46:45 -0500 Subject: [PATCH] features needed for forking --- eventloop.d | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/eventloop.d b/eventloop.d index b16560b..c7445e7 100644 --- a/eventloop.d +++ b/eventloop.d @@ -662,13 +662,26 @@ import fcntl = core.sys.posix.fcntl; import core.stdc.errno; alias int OsFileHandle; private int[2] pipes; -private void openEventPipes() { +/// you generally won't want to call this, but if you fork() +/// and then try to use the thing without exec(), you might want +/// new pipes so the events don't get mixed up. +/* private */ void openNewEventPipes() { unix.pipe(pipes); makeNonBlocking(pipes[0]); makeNonBlocking(pipes[1]); } + +// you shouldn't have to call this +void closeEventPipes() { + unix.close(pipes[0]); + unix.close(pipes[1]); + + pipes[0] = -1; + pipes[1] = -1; +} + static this() { - openEventPipes(); + openNewEventPipes(); } /* **** */