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 <edward.welbourne@qt.io>
This commit is contained in:
Thiago Macieira 2020-06-12 21:40:42 -07:00 committed by Edward Welbourne
parent ae28fbd8cc
commit 4e2f467036
4 changed files with 0 additions and 11 deletions

View File

@ -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

View File

@ -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)

View File

@ -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;

View File

@ -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;