diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-03-18 14:46:54 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-05-23 18:41:43 -0700 |
commit | c5c7712910f5de454ee0d9a30b9a848d023bb543 (patch) | |
tree | 842217c154ed0be548c40b740638ebea085ab7f8 /src/corelib/io/qprocess_unix.cpp | |
parent | 815bb2a4fb13dc2e15b87310a6b851026a50bf7d (diff) |
QProcess/Unix: allow startDetached() to also use vfork()
The same arguments that applied to the regular process-starting code in
commit e1a787a76ed462e4ed49db78a40c6d7e272182d7 (6.4) apply here too.
Task-number: QTBUG-104493
Change-Id: Icfe44ecf285a480fafe4fffd174da1b05d0054bc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Diffstat (limited to 'src/corelib/io/qprocess_unix.cpp')
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index a6851b69e9..7ae28b84dd 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -1090,7 +1090,12 @@ bool QProcessPrivate::startDetached(qint64 *pid) // see startProcess() for more information PThreadCancelGuard cancelGuard; - pid_t childPid = fork(); + auto doFork = [this]() { + if (useForkFlags(unixExtras.get())) + return fork; + QT_IGNORE_DEPRECATIONS(return vfork;) + }(); + pid_t childPid = doFork(); if (childPid == 0) { ::signal(SIGPIPE, SIG_DFL); // reset the signal that we ignored ::setsid(); @@ -1105,7 +1110,7 @@ bool QProcessPrivate::startDetached(qint64 *pid) ::_exit(1); }; - pid_t doubleForkPid = fork(); + pid_t doubleForkPid = doFork(); if (doubleForkPid == 0) { // Render channels configuration. commitChannels(); |