forked from qt-creator/qt-creator
Ssh: Re-base SshProcess on top of QtcProcess
Change-Id: I266820e0e2ea12d6e4a5a83a679a7279fab9cd83 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -36,7 +36,8 @@
|
||||
|
||||
namespace QSsh {
|
||||
|
||||
SshProcess::SshProcess()
|
||||
SshProcess::SshProcess(Utils::ProcessMode processMode)
|
||||
: Utils::QtcProcess(processMode)
|
||||
{
|
||||
Utils::Environment env = Utils::Environment::systemEnvironment();
|
||||
if (SshSettings::askpassFilePath().exists()) {
|
||||
@@ -46,37 +47,10 @@ SshProcess::SshProcess()
|
||||
if (!env.hasKey("DISPLAY"))
|
||||
env.set("DISPLAY", ":0");
|
||||
}
|
||||
setProcessEnvironment(env.toProcessEnvironment());
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && defined(Q_OS_UNIX)
|
||||
setChildProcessModifier([this] { setupChildProcess_impl(); });
|
||||
#endif
|
||||
}
|
||||
setEnvironment(env);
|
||||
|
||||
SshProcess::~SshProcess()
|
||||
{
|
||||
if (state() == QProcess::NotRunning)
|
||||
return;
|
||||
disconnect();
|
||||
terminate();
|
||||
waitForFinished(1000);
|
||||
if (state() == QProcess::NotRunning)
|
||||
return;
|
||||
kill();
|
||||
waitForFinished(1000);
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
void SshProcess::setupChildProcess()
|
||||
{
|
||||
setupChildProcess_impl();
|
||||
}
|
||||
#endif
|
||||
|
||||
void SshProcess::setupChildProcess_impl()
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
setsid(); // Otherwise, ssh will ignore SSH_ASKPASS and read from /dev/tty directly.
|
||||
#endif
|
||||
// Otherwise, ssh will ignore SSH_ASKPASS and read from /dev/tty directly.
|
||||
setDisableUnixTerminal();
|
||||
}
|
||||
|
||||
} // namespace QSsh
|
||||
|
||||
Reference in New Issue
Block a user