Utils: Add combine with device env option

Adds the option Environment::combineWithDeviceEnvironment. This allows
the linuxdevice to set it to false.

Without this option a deadlock would occur when the QtcProcess tries to
get the device environment and the device shell failed to start.
(e.g. because a required command is missing on the device).

Change-Id: I8f7550d0d90e989a339f27e993a836e67e910e33
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-01-31 09:21:39 +01:00
parent cf692bd2f6
commit fb6fc2bde8
3 changed files with 24 additions and 5 deletions

View File

@@ -359,6 +359,8 @@ public:
RunResult runInShell(const CommandLine &cmdLine,
const QByteArray &stdInData) const override;
Environment deviceEnvironment() const override;
LinuxDevicePrivate *m_dev;
};
@@ -388,6 +390,19 @@ RunResult LinuxDeviceFileAccess::runInShell(const CommandLine &cmdLine,
return m_dev->runInShell(cmdLine, stdInData);
}
Environment LinuxDeviceFileAccess::deviceEnvironment() const
{
QtcProcess getEnvProc;
getEnvProc.setCommand({FilePath("env").onDevice(m_dev->q->rootPath()), {}});
Environment inEnv;
inEnv.setCombineWithDeviceEnvironment(false);
getEnvProc.setEnvironment(inEnv);
getEnvProc.runBlocking();
const QString remoteOutput = getEnvProc.cleanedStdOut();
return Environment(remoteOutput.split('\n', Qt::SkipEmptyParts), m_dev->q->osType());
}
// SshProcessImpl
class SshProcessInterfacePrivate : public QObject