forked from qt-creator/qt-creator
Revert "Port to Qt 6's absence of QProcess::setupChildProcess"
This reverts commit 6a66ced594.
The patch that will introduce the alternative to setupChildProcess
(QProcess::setChildProcessModifier()) has not yet found its
way to qtbase and current Qt dev already identifies itself as
version 6.0.0, rendering the code here uncompilable.
Change-Id: I570b01598005070f0c17604226d245a3a381250e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -47,12 +47,6 @@ 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()
|
||||
@@ -68,13 +62,11 @@ 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
|
||||
|
||||
@@ -38,9 +38,7 @@ public:
|
||||
~SshProcess() override;
|
||||
|
||||
private:
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
void setupChildProcess() override;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace QSsh
|
||||
|
||||
@@ -678,10 +678,6 @@ QtcProcess::QtcProcess(QObject *parent)
|
||||
static int qProcessProcessErrorMeta = qRegisterMetaType<QProcess::ProcessError>();
|
||||
Q_UNUSED(qProcessExitStatusMeta)
|
||||
Q_UNUSED(qProcessProcessErrorMeta)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) && defined(Q_OS_UNIX)
|
||||
setChildProcessModifier([this]() { niceChildProcess(); });
|
||||
#endif
|
||||
}
|
||||
|
||||
void QtcProcess::setUseCtrlCStub(bool enabled)
|
||||
@@ -1224,25 +1220,18 @@ QString QtcProcess::expandMacros(const QString &str, AbstractMacroExpander *mx,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined Q_OS_UNIX
|
||||
void QtcProcess::niceChildProcess()
|
||||
void QtcProcess::setupChildProcess()
|
||||
{
|
||||
#if defined Q_OS_UNIX
|
||||
// nice value range is -20 to +19 where -20 is highest, 0 default and +19 is lowest
|
||||
if (m_lowPriority) {
|
||||
errno = 0;
|
||||
if (::nice(5) == -1 && errno != 0)
|
||||
perror("Failed to set nice value");
|
||||
}
|
||||
}
|
||||
|
||||
# if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
void QtcProcess::setupChildProcess()
|
||||
{
|
||||
niceChildProcess();
|
||||
#endif
|
||||
QProcess::setupChildProcess();
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
bool QtcProcess::ArgIterator::next()
|
||||
{
|
||||
|
||||
@@ -142,12 +142,7 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
#ifdef Q_OS_UNIX
|
||||
# if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
void setupChildProcess() override;
|
||||
# endif
|
||||
void niceChildProcess();
|
||||
#endif
|
||||
|
||||
CommandLine m_commandLine;
|
||||
Environment m_environment;
|
||||
|
||||
@@ -89,27 +89,19 @@ static Q_LOGGING_CATEGORY(processLog, "qtc.utils.synchronousprocess", QtWarningM
|
||||
// A special QProcess derivative allowing for terminal control.
|
||||
class TerminalControllingProcess : public QProcess {
|
||||
public:
|
||||
TerminalControllingProcess()
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) && defined(Q_OS_UNIX)
|
||||
setChildProcessModifier([this]() { maybeSetsid(); });
|
||||
#endif
|
||||
}
|
||||
TerminalControllingProcess() = default;
|
||||
|
||||
unsigned flags() const { return m_flags; }
|
||||
void setFlags(unsigned tc) { m_flags = tc; }
|
||||
|
||||
protected:
|
||||
inline void maybeSetsid();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0) && defined(Q_OS_UNIX)
|
||||
void setupChildProcess() override { maybeSetsid(); }
|
||||
#endif
|
||||
void setupChildProcess() override;
|
||||
|
||||
private:
|
||||
unsigned m_flags = 0;
|
||||
};
|
||||
|
||||
inline void TerminalControllingProcess::maybeSetsid()
|
||||
void TerminalControllingProcess::setupChildProcess()
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
// Disable terminal by becoming a session leader.
|
||||
|
||||
Reference in New Issue
Block a user