From 4e2f4670362d2ab8eed55be0cf699b24d658c3e6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 12 Jun 2020 21:40:42 -0700 Subject: forkfd: remove FFD_VFORK_SEMANTICS This will never work, not unless libc implements it themselves, since the child process is not allowed to return from the function that does the vfork(), as subsequent use of the stack would trash the frozen parent's return address, and in our case that's syscall(). Instead, we may add a vforkfd() function that takes a callback function that will be called in that context, like the glibc clone(3) wrapper does. Pick-to: 5.15 Change-Id: I1dba29bc0f454df09ca1fffd161800b453c00593 Reviewed-by: Edward Welbourne --- src/3rdparty/forkfd/forkfd.c | 6 ------ src/3rdparty/forkfd/forkfd.h | 1 - src/3rdparty/forkfd/forkfd_linux.c | 2 -- src/corelib/io/qprocess_unix.cpp | 2 -- 4 files changed, 11 deletions(-) diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index d7bafe086e..c29ebc299d 100644 --- a/src/3rdparty/forkfd/forkfd.c +++ b/src/3rdparty/forkfd/forkfd.c @@ -620,12 +620,6 @@ static int create_pipe(int filedes[], int flags) * fork(), such as not calling the functions registered with pthread_atfork(). * If that's necessary, pass this flag. * - * @li @c FFD_VFORK_SEMANTICS Tell forkfd() to use semantics similar to - * vfork(), if that's available. For example, on Linux with pidfd support - * available, this will add the CLONE_VFORK option. On most other systems, - * including Linux without pidfd support, this option does nothing, as using - * the actual vfork() system call would cause a race condition. - * * The file descriptor returned by forkfd() supports the following operations: * * @li read(2) When the child process exits, then the buffer supplied to diff --git a/src/3rdparty/forkfd/forkfd.h b/src/3rdparty/forkfd/forkfd.h index a864b59861..6bc1f0c1b9 100644 --- a/src/3rdparty/forkfd/forkfd.h +++ b/src/3rdparty/forkfd/forkfd.h @@ -41,7 +41,6 @@ extern "C" { #define FFD_CLOEXEC 1 #define FFD_NONBLOCK 2 #define FFD_USE_FORK 4 -#define FFD_VFORK_SEMANTICS 8 #define FFD_CHILD_PROCESS (-2) diff --git a/src/3rdparty/forkfd/forkfd_linux.c b/src/3rdparty/forkfd/forkfd_linux.c index 0984368add..923ced128d 100644 --- a/src/3rdparty/forkfd/forkfd_linux.c +++ b/src/3rdparty/forkfd/forkfd_linux.c @@ -148,8 +148,6 @@ int system_forkfd(int flags, pid_t *ppid, int *system) *system = 1; unsigned long cloneflags = CLONE_PIDFD; - if (flags & FFD_VFORK_SEMANTICS) - cloneflags |= CLONE_VFORK; pid = sys_clone(cloneflags, &pidfd); if (pid < 0) return pid; diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index e8efe6481f..50390e57f5 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -461,8 +461,6 @@ void QProcessPrivate::startProcess() int ffdflags = FFD_CLOEXEC; if (typeid(*q) != typeid(QProcess)) ffdflags |= FFD_USE_FORK; - else - ffdflags |= FFD_VFORK_SEMANTICS; pid_t childPid; forkfd = ::forkfd(ffdflags , &childPid); int lastForkErrno = errno; -- cgit v1.2.3