forked from qt-creator/qt-creator
Utils: Add the ability to interrupt inferiors via the process stub
This will be handy once we want to debug processes running as root. The mechanism is the same as for "killProcess", and currently unused. Change-Id: I2c5e5b77577ca32ed1118fcc81c03c6320db8800 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
@@ -604,6 +604,18 @@ bool ConsoleProcess::start()
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConsoleProcess::interruptProcess()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
// Not used.
|
||||
#else
|
||||
if (d->m_stubSocket && d->m_stubSocket->isWritable()) {
|
||||
d->m_stubSocket->write("i", 1);
|
||||
d->m_stubSocket->flush();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ConsoleProcess::killProcess()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
|
@@ -87,6 +87,7 @@ public:
|
||||
bool isRunning() const; // This reflects the state of the console+stub
|
||||
qint64 applicationPID() const;
|
||||
|
||||
void interruptProcess();
|
||||
void killProcess();
|
||||
void killStub();
|
||||
|
||||
|
@@ -346,6 +346,13 @@ int main(int argc, char *argv[])
|
||||
kill(chldPid, SIGKILL);
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
if (chldPid > 0) {
|
||||
int res = kill(chldPid, SIGINT);
|
||||
if (res)
|
||||
perror("Stub could not interrupt inferior");
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
isDetached = 1;
|
||||
break;
|
||||
|
@@ -183,6 +183,11 @@ TerminalRunner::TerminalRunner(RunControl *runControl, const Runnable &stubRunna
|
||||
this, [this] { reportDone(); });
|
||||
}
|
||||
|
||||
void TerminalRunner::interruptProcess()
|
||||
{
|
||||
m_stubProc.interruptProcess();
|
||||
}
|
||||
|
||||
void TerminalRunner::start()
|
||||
{
|
||||
m_stubProc.setEnvironment(m_stubRunnable.environment);
|
||||
|
@@ -77,6 +77,8 @@ public:
|
||||
qint64 applicationPid() const { return m_applicationPid; }
|
||||
qint64 applicationMainThreadId() const { return m_applicationMainThreadId; }
|
||||
|
||||
void interruptProcess();
|
||||
|
||||
private:
|
||||
void start() final;
|
||||
void stop() final;
|
||||
|
Reference in New Issue
Block a user