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:
parent
ae28fbd8cc
commit
4e2f467036
6
src/3rdparty/forkfd/forkfd.c
vendored
6
src/3rdparty/forkfd/forkfd.c
vendored
@ -620,12 +620,6 @@ static int create_pipe(int filedes[], int flags)
|
|||||||
* fork(), such as not calling the functions registered with pthread_atfork().
|
* fork(), such as not calling the functions registered with pthread_atfork().
|
||||||
* If that's necessary, pass this flag.
|
* 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:
|
* The file descriptor returned by forkfd() supports the following operations:
|
||||||
*
|
*
|
||||||
* @li read(2) When the child process exits, then the buffer supplied to
|
* @li read(2) When the child process exits, then the buffer supplied to
|
||||||
|
1
src/3rdparty/forkfd/forkfd.h
vendored
1
src/3rdparty/forkfd/forkfd.h
vendored
@ -41,7 +41,6 @@ extern "C" {
|
|||||||
#define FFD_CLOEXEC 1
|
#define FFD_CLOEXEC 1
|
||||||
#define FFD_NONBLOCK 2
|
#define FFD_NONBLOCK 2
|
||||||
#define FFD_USE_FORK 4
|
#define FFD_USE_FORK 4
|
||||||
#define FFD_VFORK_SEMANTICS 8
|
|
||||||
|
|
||||||
#define FFD_CHILD_PROCESS (-2)
|
#define FFD_CHILD_PROCESS (-2)
|
||||||
|
|
||||||
|
2
src/3rdparty/forkfd/forkfd_linux.c
vendored
2
src/3rdparty/forkfd/forkfd_linux.c
vendored
@ -148,8 +148,6 @@ int system_forkfd(int flags, pid_t *ppid, int *system)
|
|||||||
|
|
||||||
*system = 1;
|
*system = 1;
|
||||||
unsigned long cloneflags = CLONE_PIDFD;
|
unsigned long cloneflags = CLONE_PIDFD;
|
||||||
if (flags & FFD_VFORK_SEMANTICS)
|
|
||||||
cloneflags |= CLONE_VFORK;
|
|
||||||
pid = sys_clone(cloneflags, &pidfd);
|
pid = sys_clone(cloneflags, &pidfd);
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
return pid;
|
return pid;
|
||||||
|
@ -461,8 +461,6 @@ void QProcessPrivate::startProcess()
|
|||||||
int ffdflags = FFD_CLOEXEC;
|
int ffdflags = FFD_CLOEXEC;
|
||||||
if (typeid(*q) != typeid(QProcess))
|
if (typeid(*q) != typeid(QProcess))
|
||||||
ffdflags |= FFD_USE_FORK;
|
ffdflags |= FFD_USE_FORK;
|
||||||
else
|
|
||||||
ffdflags |= FFD_VFORK_SEMANTICS;
|
|
||||||
pid_t childPid;
|
pid_t childPid;
|
||||||
forkfd = ::forkfd(ffdflags , &childPid);
|
forkfd = ::forkfd(ffdflags , &childPid);
|
||||||
int lastForkErrno = errno;
|
int lastForkErrno = errno;
|
||||||
|
Loading…
Reference in New Issue
Block a user