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");
|
env.set("DISPLAY", ":0");
|
||||||
}
|
}
|
||||||
setProcessEnvironment(env.toProcessEnvironment());
|
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()
|
SshProcess::~SshProcess()
|
||||||
@@ -68,13 +62,11 @@ SshProcess::~SshProcess()
|
|||||||
waitForFinished(1000);
|
waitForFinished(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
|
||||||
void SshProcess::setupChildProcess()
|
void SshProcess::setupChildProcess()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
setsid(); // Otherwise, ssh will ignore SSH_ASKPASS and read from /dev/tty directly.
|
setsid(); // Otherwise, ssh will ignore SSH_ASKPASS and read from /dev/tty directly.
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace QSsh
|
} // namespace QSsh
|
||||||
|
|||||||
@@ -38,9 +38,7 @@ public:
|
|||||||
~SshProcess() override;
|
~SshProcess() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
|
||||||
void setupChildProcess() override;
|
void setupChildProcess() override;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QSsh
|
} // namespace QSsh
|
||||||
|
|||||||
@@ -678,10 +678,6 @@ QtcProcess::QtcProcess(QObject *parent)
|
|||||||
static int qProcessProcessErrorMeta = qRegisterMetaType<QProcess::ProcessError>();
|
static int qProcessProcessErrorMeta = qRegisterMetaType<QProcess::ProcessError>();
|
||||||
Q_UNUSED(qProcessExitStatusMeta)
|
Q_UNUSED(qProcessExitStatusMeta)
|
||||||
Q_UNUSED(qProcessProcessErrorMeta)
|
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)
|
void QtcProcess::setUseCtrlCStub(bool enabled)
|
||||||
@@ -1224,25 +1220,18 @@ QString QtcProcess::expandMacros(const QString &str, AbstractMacroExpander *mx,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined Q_OS_UNIX
|
void QtcProcess::setupChildProcess()
|
||||||
void QtcProcess::niceChildProcess()
|
|
||||||
{
|
{
|
||||||
|
#if defined Q_OS_UNIX
|
||||||
// nice value range is -20 to +19 where -20 is highest, 0 default and +19 is lowest
|
// nice value range is -20 to +19 where -20 is highest, 0 default and +19 is lowest
|
||||||
if (m_lowPriority) {
|
if (m_lowPriority) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (::nice(5) == -1 && errno != 0)
|
if (::nice(5) == -1 && errno != 0)
|
||||||
perror("Failed to set nice value");
|
perror("Failed to set nice value");
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
# if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
|
||||||
void QtcProcess::setupChildProcess()
|
|
||||||
{
|
|
||||||
niceChildProcess();
|
|
||||||
QProcess::setupChildProcess();
|
QProcess::setupChildProcess();
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool QtcProcess::ArgIterator::next()
|
bool QtcProcess::ArgIterator::next()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -142,12 +142,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
# if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
|
||||||
void setupChildProcess() override;
|
void setupChildProcess() override;
|
||||||
# endif
|
|
||||||
void niceChildProcess();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CommandLine m_commandLine;
|
CommandLine m_commandLine;
|
||||||
Environment m_environment;
|
Environment m_environment;
|
||||||
|
|||||||
@@ -89,27 +89,19 @@ static Q_LOGGING_CATEGORY(processLog, "qtc.utils.synchronousprocess", QtWarningM
|
|||||||
// A special QProcess derivative allowing for terminal control.
|
// A special QProcess derivative allowing for terminal control.
|
||||||
class TerminalControllingProcess : public QProcess {
|
class TerminalControllingProcess : public QProcess {
|
||||||
public:
|
public:
|
||||||
TerminalControllingProcess()
|
TerminalControllingProcess() = default;
|
||||||
{
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) && defined(Q_OS_UNIX)
|
|
||||||
setChildProcessModifier([this]() { maybeSetsid(); });
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned flags() const { return m_flags; }
|
unsigned flags() const { return m_flags; }
|
||||||
void setFlags(unsigned tc) { m_flags = tc; }
|
void setFlags(unsigned tc) { m_flags = tc; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline void maybeSetsid();
|
void setupChildProcess() override;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0) && defined(Q_OS_UNIX)
|
|
||||||
void setupChildProcess() override { maybeSetsid(); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned m_flags = 0;
|
unsigned m_flags = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void TerminalControllingProcess::maybeSetsid()
|
void TerminalControllingProcess::setupChildProcess()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
// Disable terminal by becoming a session leader.
|
// Disable terminal by becoming a session leader.
|
||||||
|
|||||||
Reference in New Issue
Block a user