Port to Qt 6's absence of QProcess::setupChildProcess

Change-Id: I9709abb1c3734e10a7defffd1607e5b3fd46af0e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Thiago Macieira
2020-04-21 10:25:54 -07:00
parent 7e6e02eb08
commit 6a66ced594
5 changed files with 40 additions and 6 deletions

View File

@@ -47,6 +47,12 @@ SshProcess::SshProcess()
env.set("DISPLAY", ":0");
}
setProcessEnvironment(env.toProcessEnvironment());
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) && defined(Q_OS_UNIX)
setChildProcessModifier([]() {
setsid(); // Otherwise, ssh will ignore SSH_ASKPASS and read from /dev/tty directly.
});
#endif
}
SshProcess::~SshProcess()
@@ -62,11 +68,13 @@ SshProcess::~SshProcess()
waitForFinished(1000);
}
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
void SshProcess::setupChildProcess()
{
#ifdef Q_OS_UNIX
setsid(); // Otherwise, ssh will ignore SSH_ASKPASS and read from /dev/tty directly.
#endif
}
#endif
} // namespace QSsh