From c5c7712910f5de454ee0d9a30b9a848d023bb543 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 18 Mar 2023 14:46:54 -0700 Subject: [PATCH] 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 Reviewed-by: Qt CI Bot Reviewed-by: Oswald Buddenhagen Reviewed-by: Marcus Tillmanns --- src/corelib/io/qprocess_unix.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index a6851b69e9f..7ae28b84dd8 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();