summaryrefslogtreecommitdiff
path: root/src/corelib/io/qprocess_unix.cpp
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2023-03-23 21:06:47 +0200
committerTarja Sundqvist <tarja.sundqvist@qt.io>2023-03-23 21:06:47 +0200
commit42e4ae042a4c86e58bcb8b6d2d59ba4a988285b4 (patch)
treea7f25b1d335a834a7c3ae104cee913ef3a4dd4fb /src/corelib/io/qprocess_unix.cpp
parent4ee4fc18b4067b90efa46ca9baba74f53b54d9ec (diff)
parent168ff3419f256fdb35b586275d293fc0cd773fe1 (diff)
downloadqtbase-42e4ae042a4c86e58bcb8b6d2d59ba4a988285b4.tar.gz
Merge remote-tracking branch 'origin/tqtc/lts-5.15.9' into tqtc/lts-5.15-opensourcev5.15.9-lts-lgpl5.15
Change-Id: Iaff6b55275e50d19973e1020853d8622587069f9
Diffstat (limited to 'src/corelib/io/qprocess_unix.cpp')
-rw-r--r--src/corelib/io/qprocess_unix.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 50390e57f5..0435180fa8 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
+** Copyright (C) 2021 The Qt Company Ltd.
+** Copyright (C) 2022 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -422,14 +422,14 @@ void QProcessPrivate::startProcess()
// Add the program name to the argument list.
argv[0] = nullptr;
if (!program.contains(QLatin1Char('/'))) {
+ // findExecutable() returns its argument if it's an absolute path,
+ // otherwise it searches $PATH; returns empty if not found (we handle
+ // that case much later)
const QString &exeFilePath = QStandardPaths::findExecutable(program);
- if (!exeFilePath.isEmpty()) {
- const QByteArray &tmp = QFile::encodeName(exeFilePath);
- argv[0] = ::strdup(tmp.constData());
- }
- }
- if (!argv[0])
+ argv[0] = ::strdup(QFile::encodeName(exeFilePath).constData());
+ } else {
argv[0] = ::strdup(encodedProgramName.constData());
+ }
// Add every argument to the list
for (int i = 0; i < arguments.count(); ++i)
@@ -985,12 +985,14 @@ bool QProcessPrivate::startDetached(qint64 *pid)
QByteArray tmp;
if (!program.contains(QLatin1Char('/'))) {
+ // findExecutable() returns its argument if it's an absolute path,
+ // otherwise it searches $PATH; returns empty if not found (we handle
+ // that case much later)
const QString &exeFilePath = QStandardPaths::findExecutable(program);
- if (!exeFilePath.isEmpty())
- tmp = QFile::encodeName(exeFilePath);
- }
- if (tmp.isEmpty())
+ tmp = QFile::encodeName(exeFilePath);
+ } else {
tmp = QFile::encodeName(program);
+ }
argv[0] = tmp.data();
if (envp)