diff --git a/mitogen/core.py b/mitogen/core.py index 2769021e..c6220d64 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -162,6 +162,11 @@ def set_nonblock(fd): fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) +def set_block(fd): + flags = fcntl.fcntl(fd, fcntl.F_GETFL) + fcntl.fcntl(fd, fcntl.F_SETFL, flags & ~os.O_NONBLOCK) + + def io_op(func, *args): try: return func(*args), False diff --git a/mitogen/master.py b/mitogen/master.py index 37829e41..2e30eaf4 100644 --- a/mitogen/master.py +++ b/mitogen/master.py @@ -102,6 +102,7 @@ def create_child(*args): parentfp, childfp = socket.socketpair() pid = os.fork() if not pid: + mitogen.core.set_block(childfp.fileno()) os.dup2(childfp.fileno(), 0) os.dup2(childfp.fileno(), 1) childfp.close()