diff options
Diffstat (limited to 'src/corelib/io/qprocess_p.h')
-rw-r--r-- | src/corelib/io/qprocess_p.h | 96 |
1 files changed, 27 insertions, 69 deletions
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index 4b38f191d5..9510101e74 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QPROCESS_P_H #define QPROCESS_P_H @@ -295,29 +259,12 @@ public: bool _q_startupNotification(); void _q_processDied(); - QProcess::ProcessChannelMode processChannelMode = QProcess::SeparateChannels; - QProcess::InputChannelMode inputChannelMode = QProcess::ManagedInputChannel; - QProcess::ProcessError processError = QProcess::UnknownError; - QProcess::ProcessState processState = QProcess::NotRunning; - QString workingDirectory; -#ifdef Q_OS_WIN - Q_PROCESS_INFORMATION *pid = nullptr; -#else - qint64 pid = 0; -#endif - - bool emittedReadyRead = false; - bool emittedBytesWritten = false; - Channel stdinChannel; Channel stdoutChannel; Channel stderrChannel; bool openChannels(); bool openChannelsForDetached(); bool openChannel(Channel &channel); -#if defined(Q_OS_UNIX) - void commitChannels(); -#endif void closeChannel(Channel *channel); void closeWriteChannel(); void closeChannels(); @@ -325,26 +272,38 @@ public: QString program; QStringList arguments; + QString workingDirectory; + QProcessEnvironment environment = QProcessEnvironment::InheritFromParent; #if defined(Q_OS_WIN) QString nativeArguments; QProcess::CreateProcessArgumentModifier modifyCreateProcessArgs; + QWinEventNotifier *processFinishedNotifier = nullptr; + Q_PROCESS_INFORMATION *pid = nullptr; #else - std::function<void(void)> childProcessModifier; -#endif - QProcessEnvironment environment; - -#ifdef Q_OS_UNIX - Q_PIPE childStartedPipe[2] = {INVALID_Q_PIPE, INVALID_Q_PIPE}; + struct UnixExtras { + std::function<void(void)> childProcessModifier; + QProcess::UnixProcessParameters processParameters; + }; + std::unique_ptr<UnixExtras> unixExtras; QSocketNotifier *stateNotifier = nullptr; + Q_PIPE childStartedPipe[2] = {INVALID_Q_PIPE, INVALID_Q_PIPE}; + pid_t pid = 0; int forkfd = -1; -#else - QWinEventNotifier *processFinishedNotifier = nullptr; #endif + int exitCode = 0; + quint8 processState = QProcess::NotRunning; + quint8 exitStatus = QProcess::NormalExit; + quint8 processError = QProcess::UnknownError; + quint8 processChannelMode = QProcess::SeparateChannels; + quint8 inputChannelMode = QProcess::ManagedInputChannel; + bool emittedReadyRead = false; + bool emittedBytesWritten = false; + void start(QIODevice::OpenMode mode); void startProcess(); #if defined(Q_OS_UNIX) - void execChild(const char *workingDirectory, char **argv, char **envp); + void commitChannels() const; #endif bool processStarted(QString *errorMessage = nullptr); void processFinished(); @@ -363,10 +322,6 @@ public: bool startDetached(qint64 *pPid); - int exitCode = 0; - QProcess::ExitStatus exitStatus = QProcess::NormalExit; - bool crashed = false; - bool waitForStarted(const QDeadlineTimer &deadline); bool waitForReadyRead(const QDeadlineTimer &deadline); bool waitForBytesWritten(const QDeadlineTimer &deadline); @@ -379,6 +334,9 @@ public: void cleanup(); void setError(QProcess::ProcessError error, const QString &description = QString()); void setErrorAndEmit(QProcess::ProcessError error, const QString &description = QString()); + + const QProcessEnvironmentPrivate *environmentPrivate() const + { return environment.d.constData(); } }; #endif // QT_CONFIG(process) |