mirror of https://github.com/adamdruppe/arsd.git
features needed for forking
This commit is contained in:
parent
c3a5240a17
commit
0906e8f7b0
17
eventloop.d
17
eventloop.d
|
@ -662,13 +662,26 @@ import fcntl = core.sys.posix.fcntl;
|
||||||
import core.stdc.errno;
|
import core.stdc.errno;
|
||||||
alias int OsFileHandle;
|
alias int OsFileHandle;
|
||||||
private int[2] pipes;
|
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);
|
unix.pipe(pipes);
|
||||||
makeNonBlocking(pipes[0]);
|
makeNonBlocking(pipes[0]);
|
||||||
makeNonBlocking(pipes[1]);
|
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() {
|
static this() {
|
||||||
openEventPipes();
|
openNewEventPipes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* **** */
|
/* **** */
|
||||||
|
|
Loading…
Reference in New Issue