util-src/pposix.c
changeset 7443 5424e24cdcb1
parent 6945 f12deb882148
child 7792 93dd90309779
--- a/util-src/pposix.c	Wed May 25 16:54:43 2016 +0200
+++ b/util-src/pposix.c	Wed May 25 21:34:34 2016 +0200
@@ -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) {