util.pposix: Ask for shared file descriptor table using rfork() on *BSD (fixes #412)
authorKim Alvefur <zash@zash.se>
Wed, 25 May 2016 19:34:34 +0000 (21:34 +0200)
committerKim Alvefur <zash@zash.se>
Wed, 25 May 2016 19:34:34 +0000 (21:34 +0200)
util-src/pposix.c

index 1b69852d2a703cacf2619adeffe821ad5ddb3b94..b48465d3a75461bd6a9ee216fbace132d81e647c 100644 (file)
 #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) {