forked from qt-creator/qt-creator
Utils: Merge TerminalControllingProcess into QtcProcess
Effectively only a single flag controlling a call to setsid(). Change-Id: I6a2be35df1bddc81702575678ee3a065a71cecf5 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -1270,6 +1270,10 @@ void QtcProcess::setupChildProcess_impl()
|
|||||||
if (::nice(5) == -1 && errno != 0)
|
if (::nice(5) == -1 && errno != 0)
|
||||||
perror("Failed to set nice value");
|
perror("Failed to set nice value");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable terminal by becoming a session leader.
|
||||||
|
if (m_disableUnixTerminal)
|
||||||
|
setsid();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,6 +46,7 @@ public:
|
|||||||
void terminate();
|
void terminate();
|
||||||
void interrupt();
|
void interrupt();
|
||||||
void setLowPriority() { m_lowPriority = true; }
|
void setLowPriority() { m_lowPriority = true; }
|
||||||
|
void setDisableUnixTerminal() { m_disableUnixTerminal = true; }
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Arguments
|
class QTCREATOR_UTILS_EXPORT Arguments
|
||||||
{
|
{
|
||||||
@@ -177,6 +178,7 @@ private:
|
|||||||
bool m_haveEnv = false;
|
bool m_haveEnv = false;
|
||||||
bool m_useCtrlCStub = false;
|
bool m_useCtrlCStub = false;
|
||||||
bool m_lowPriority = false;
|
bool m_lowPriority = false;
|
||||||
|
bool m_disableUnixTerminal = false;
|
||||||
|
|
||||||
bool m_synchronous = false;
|
bool m_synchronous = false;
|
||||||
OpenMode m_openMode = ReadWrite;
|
OpenMode m_openMode = ReadWrite;
|
||||||
|
@@ -43,10 +43,6 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Utils::SynchronousProcess
|
\class Utils::SynchronousProcess
|
||||||
|
|
||||||
@@ -87,48 +83,6 @@ namespace Utils {
|
|||||||
|
|
||||||
static Q_LOGGING_CATEGORY(processLog, "qtc.utils.synchronousprocess", QtWarningMsg);
|
static Q_LOGGING_CATEGORY(processLog, "qtc.utils.synchronousprocess", QtWarningMsg);
|
||||||
|
|
||||||
// A special QProcess derivative allowing for terminal control.
|
|
||||||
class TerminalControllingProcess : public QtcProcess
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TerminalControllingProcess();
|
|
||||||
|
|
||||||
void setDisableUnixTerminal() { m_disableUnixTerminal = true; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
void setupChildProcess() override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setupChildProcess_impl();
|
|
||||||
|
|
||||||
bool m_disableUnixTerminal = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
TerminalControllingProcess::TerminalControllingProcess()
|
|
||||||
{
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && defined(Q_OS_UNIX)
|
|
||||||
setChildProcessModifier([this] { setupChildProcess_impl(); });
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
void TerminalControllingProcess::setupChildProcess()
|
|
||||||
{
|
|
||||||
setupChildProcess_impl();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void TerminalControllingProcess::setupChildProcess_impl()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
// Disable terminal by becoming a session leader.
|
|
||||||
if (m_disableUnixTerminal)
|
|
||||||
setsid();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------- SynchronousProcessResponse
|
// ----------- SynchronousProcessResponse
|
||||||
void SynchronousProcessResponse::clear()
|
void SynchronousProcessResponse::clear()
|
||||||
{
|
{
|
||||||
@@ -286,7 +240,7 @@ public:
|
|||||||
void clearForRun();
|
void clearForRun();
|
||||||
|
|
||||||
QTextCodec *m_codec = QTextCodec::codecForLocale();
|
QTextCodec *m_codec = QTextCodec::codecForLocale();
|
||||||
TerminalControllingProcess m_process;
|
QtcProcess m_process;
|
||||||
QTimer m_timer;
|
QTimer m_timer;
|
||||||
QEventLoop m_eventLoop;
|
QEventLoop m_eventLoop;
|
||||||
SynchronousProcessResponse m_result;
|
SynchronousProcessResponse m_result;
|
||||||
|
Reference in New Issue
Block a user