diff options
Diffstat (limited to 'src/3rdparty/forkfd/forkfd.c')
-rw-r--r-- | src/3rdparty/forkfd/forkfd.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index e4f3bd85de..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); @@ -822,6 +830,8 @@ int forkfd_close(int ffd) #if defined(__FreeBSD__) && __FreeBSD__ >= 9 # include "forkfd_freebsd.c" +#elif defined(__linux__) +# include "forkfd_linux.c" #else int system_has_forkfd() { |