From 78958d574097e2b8ceb2811d257ef4348e741a03 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 6 Jul 2022 16:43:06 +0200 Subject: [PATCH] TerminalProcess: Emit done() signal when stop() was called When we call QtcProcess::stop(), the terminal process invokes stopProcess() method. However, if it doesn't emit done() then subsequent call to waitForFinished() will timeout with 30 s. This should fix the 30 seconds hang when debugging in terminal after pressing the red square button. Change-Id: Iea1f9ade85dc8a4414dc49d7c8a2cbe80f0b5756 Reviewed-by: Cristian Adam Reviewed-by: David Schulz --- src/libs/utils/terminalprocess.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/libs/utils/terminalprocess.cpp b/src/libs/utils/terminalprocess.cpp index 556ae5dc3c0..17a15adc4a1 100644 --- a/src/libs/utils/terminalprocess.cpp +++ b/src/libs/utils/terminalprocess.cpp @@ -483,29 +483,26 @@ void TerminalImpl::killProcess() void TerminalImpl::killStub() { + if (!isRunning()) + return; + #ifdef Q_OS_WIN - if (d->m_pid) { - TerminateProcess(d->m_pid->hProcess, (unsigned)-1); - WaitForSingleObject(d->m_pid->hProcess, INFINITE); - cleanupStub(); - } + TerminateProcess(d->m_pid->hProcess, (unsigned)-1); + WaitForSingleObject(d->m_pid->hProcess, INFINITE); + cleanupStub(); #else sendCommand('s'); stubServerShutdown(); + d->m_process.waitForFinished(); #endif + + emitFinished(-1, QProcess::CrashExit); } void TerminalImpl::stopProcess() { killProcess(); killStub(); - if (isRunning() && HostOsInfo::isAnyUnixHost()) { - d->m_process.terminate(); - if (!d->m_process.waitForFinished(1000) && d->m_process.state() == QProcess::Running) { - d->m_process.kill(); - d->m_process.waitForFinished(); - } - } } bool TerminalImpl::isRunning() const