summaryrefslogtreecommitdiffstats
path: root/src/3rdparty
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-03-13 23:53:35 -0700
committerThiago Macieira <thiago.macieira@intel.com>2015-07-28 23:55:11 +0000
commit93cb98417470d7172ac31df2c12634c5969c43e7 (patch)
tree90d83318076fe4da3c1ac7de70bf39cf0eab6e4e /src/3rdparty
parentcfae3ed8ddce9bb04c6c70025aa947d6e4306af3 (diff)
forkfd: introduce system_forkfd to do system calls that do forkfd
This is just to make the code cleaner. The static variable will control whether we've detected that the system call exists -- if it does, we are expected to always use it. Change-Id: Iee8cbc07c4434ce9b560ffff13cb4adc049413c1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Diffstat (limited to 'src/3rdparty')
-rw-r--r--src/3rdparty/forkfd/forkfd.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c
index 5d62f88149..39eeb6a202 100644
--- a/src/3rdparty/forkfd/forkfd.c
+++ b/src/3rdparty/forkfd/forkfd.c
@@ -500,6 +500,14 @@ static int create_pipe(int filedes[], int flags)
return ret;
}
+static const int system_has_forkfd = 0;
+static int system_forkfd(int flags, pid_t *ppid)
+{
+ (void)flags;
+ (void)ppid;
+ return -1;
+}
+
#ifndef FORKFD_NO_FORKFD
/**
* @brief forkfd returns a file descriptor representing a child process
@@ -547,6 +555,12 @@ int forkfd(int flags, pid_t *ppid)
int efd;
#endif
+ if (system_has_forkfd) {
+ ret = system_forkfd(flags, ppid);
+ if (system_has_forkfd)
+ return ret;
+ }
+
(void) pthread_once(&forkfd_initialization, forkfd_initialize);
info = allocateInfo(&header);
@@ -670,6 +684,8 @@ int spawnfd(int flags, pid_t *ppid, const char *path, const posix_spawn_file_act
/* we can only do work if we have a way to start the child in stopped mode;
* otherwise, we have a major race condition. */
+ assert(!system_has_forkfd);
+
(void) pthread_once(&forkfd_initialization, forkfd_initialize);
info = allocateInfo(&header);