Changeset

7440:5424e24cdcb1

util.pposix: Ask for shared file descriptor table using rfork() on *BSD (fixes #412)
author Kim Alvefur <zash@zash.se>
date Wed, 25 May 2016 21:34:34 +0200
parents 7439:4cccaa33b0a1
children 7441:df1be36f87b1 7442:156c95bfed0b
files util-src/pposix.c
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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) {