From f6d29ba45f7d0ea7338666025319e1b2dd3f25f3 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 25 May 2016 21:34:34 +0200 Subject: [PATCH] util.pposix: Ask for shared file descriptor table using rfork() on *BSD (fixes #412) --- util-src/pposix.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/util-src/pposix.c b/util-src/pposix.c index 1b69852d..b48465d3 100644 --- a/util-src/pposix.c +++ b/util-src/pposix.c @@ -49,6 +49,19 @@ #define WITH_MALLINFO #endif +#if defined(RFPROC) && defined(EV_SET) +/* + * On *BSD, calling fork() is equivalent to rfork(RFPROC | RFFDG). + * + * RFFDG being set means that the file descriptor table is copied, + * otherwise it's shared. We want the later, otherwise libevent gets + * messed up. + * + * See issue #412 + */ +#define fork() rfork(RFPROC) +#endif + /* Daemonization support */ static int lc_daemonize(lua_State* L) { -- 2.30.2