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>
This commit is contained in:
parent
cfae3ed8dd
commit
93cb984174
16
src/3rdparty/forkfd/forkfd.c
vendored
16
src/3rdparty/forkfd/forkfd.c
vendored
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user