Terminal: Fix exit reporting in error cases

Previously the finished signal was sent not sent soon enough
for the Process to recognizes it correctly.

Also, the process stub would exit prematurely in cases of crashes.

The process stub should only return an error exit code if it did not
show the "waiting for keypress" message.

Fixes: QTCREATORBUG-29350
Change-Id: I86f7d75bacbdb5ee2b0009669926d94b6a75346a
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-06-30 10:14:54 +02:00
parent 9a04490de7
commit 6b8473a2e8
2 changed files with 5 additions and 5 deletions

View File

@@ -280,8 +280,10 @@ void TerminalInterface::sendCommand(char c)
void TerminalInterface::killInferiorProcess() void TerminalInterface::killInferiorProcess()
{ {
sendCommand('k'); sendCommand('k');
if (d->stubSocket) if (d->stubSocket) {
d->stubSocket->waitForReadyRead(); d->stubSocket->waitForReadyRead();
emitFinished(-1, QProcess::CrashExit);
}
} }
void TerminalInterface::killStubProcess() void TerminalInterface::killStubProcess()

View File

@@ -185,7 +185,7 @@ void doExit(int exitCode)
std::cout << commandLineParser.value("wait").toStdString() << std::endl; std::cout << commandLineParser.value("wait").toStdString() << std::endl;
waitingForExitKeyPress = true; waitingForExitKeyPress = true;
onKeyPress([exitCode] { doExit(exitCode); }); onKeyPress([] { doExit(0); });
} else { } else {
exit(exitCode); exit(exitCode);
} }
@@ -206,9 +206,7 @@ void onInferiorFinished(int exitCode, QProcess::ExitStatus status)
void onInferiorErrorOccurered(QProcess::ProcessError error) void onInferiorErrorOccurered(QProcess::ProcessError error)
{ {
qCInfo(log) << "Inferior error: " << error << inferiorProcess.errorString(); qCWarning(log) << "Inferior error: " << error << inferiorProcess.errorString();
sendCrash(inferiorProcess.exitCode());
doExit(1);
} }
void onInferiorStarted() void onInferiorStarted()