summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2019-11-21 15:30:01 +0100
committerThiago Macieira <thiago.macieira@intel.com>2020-01-09 22:52:25 +0100
commit702e49eeb5654b6881f91618e5bc95853e206b6c (patch)
treeb1a8b52455f7a865a492b598a2ba7e1a90a1f912 /src
parent079fbebb6ab91479107e84e2c81966ca5f157529 (diff)
forkfd: add FFD_USE_FORK to force use of fork()
Change-Id: Ia2aa807ffa8a4c798425fffd15d933e47919247a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/forkfd/forkfd.c14
-rw-r--r--src/3rdparty/forkfd/forkfd.h5
2 files changed, 14 insertions, 5 deletions
diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c
index 2ae85d6f37..31189fa2cd 100644
--- a/src/3rdparty/forkfd/forkfd.c
+++ b/src/3rdparty/forkfd/forkfd.c
@@ -586,6 +586,12 @@ static int create_pipe(int filedes[], int flags)
* descriptor. You probably want to set this flag, since forkfd() does not work
* if the original parent process dies.
*
+ * @li @C FFD_USE_FORK Tell forkfd() to actually call fork() instead of a
+ * different system implementation that may be available. On systems where a
+ * different implementation is available, its behavior may differ from that of
+ * fork(), such as not calling the functions registered with pthread_atfork().
+ * If that's necessary, pass this flag.
+ *
* The file descriptor returned by forkfd() supports the following operations:
*
* @li read(2) When the child process exits, then the buffer supplied to
@@ -613,9 +619,11 @@ int forkfd(int flags, pid_t *ppid)
int efd;
#endif
- fd = system_forkfd(flags, ppid, &ret);
- if (ret)
- return fd;
+ if ((flags & FFD_USE_FORK) == 0) {
+ fd = system_forkfd(flags, ppid, &ret);
+ if (ret)
+ return fd;
+ }
(void) pthread_once(&forkfd_initialization, forkfd_initialize);
diff --git a/src/3rdparty/forkfd/forkfd.h b/src/3rdparty/forkfd/forkfd.h
index eb121de593..fe70371719 100644
--- a/src/3rdparty/forkfd/forkfd.h
+++ b/src/3rdparty/forkfd/forkfd.h
@@ -38,8 +38,9 @@
extern "C" {
#endif
-#define FFD_CLOEXEC 1
-#define FFD_NONBLOCK 2
+#define FFD_CLOEXEC 1
+#define FFD_NONBLOCK 2
+#define FFD_USE_FORK 4
#define FFD_CHILD_PROCESS (-2)