QProcess: use FFD_USE_FORK when the class is not QProcess itself
If the user derived from QProcess, it's likely to override the setupChildProcess() virtual. Unlike fork(), the system calls for enhenced functionality (FreeBSD pdfork() and Linux's clone()) won't call pthread_atfork() callbacks and the environment in the child process could be inconsistent. Qt's own code is safe, but we can't make the same statement about users' code. So we err on the safe side for correctness and run the old, less safe implementation (thread-unsafe, subject to hijacking of the signal handler, etc.). Change-Id: Ia2aa807ffa8a4c798425fffd15d9703bd03f6f09 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
702e49eeb5
commit
97645478de
@ -451,8 +451,13 @@ void QProcessPrivate::startProcess()
|
||||
}
|
||||
|
||||
// Start the process manager, and fork off the child process.
|
||||
// ### Qt6: revisit whether the change in behavior due to not using fork()
|
||||
// is acceptable for derived classes.
|
||||
int ffdflags = FFD_CLOEXEC;
|
||||
if (typeid(*q) != typeid(QProcess))
|
||||
ffdflags |= FFD_USE_FORK;
|
||||
pid_t childPid;
|
||||
forkfd = ::forkfd(FFD_CLOEXEC, &childPid);
|
||||
forkfd = ::forkfd(ffdflags , &childPid);
|
||||
int lastForkErrno = errno;
|
||||
if (forkfd != FFD_CHILD_PROCESS) {
|
||||
// Parent process.
|
||||
|
Loading…
Reference in New Issue
Block a user