Git/VCS: Use ctrlc stub for process execution

This ensures that child processes are also terminated.

Required specifically for Git on Windows, when running in cmd directory,
which spawns a child process for usr/bin/git. On this case, if git takes
long to finish and is aborted while running, the main process was killed
as expected, but the child process remained alive.

Task-number: QTCREATORBUG-27567
Change-Id: I40271eb42cfaefd81f2fe5af138254ab0a2c8da8
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Orgad Shaneh
2022-12-14 12:37:34 +02:00
committed by Orgad Shaneh
parent 3a90977da0
commit 371e674967
5 changed files with 5 additions and 0 deletions

View File

@@ -885,6 +885,7 @@ void BranchModel::updateUpstreamStatus(BranchNode *node)
process->setCommand({d->client->vcsBinary(), {"rev-list", "--no-color", "--left-right", process->setCommand({d->client->vcsBinary(), {"rev-list", "--no-color", "--left-right",
"--count", node->fullRef() + "..." + node->tracking}}); "--count", node->fullRef() + "..." + node->tracking}});
process->setWorkingDirectory(d->workingDirectory); process->setWorkingDirectory(d->workingDirectory);
process->setUseCtrlCStub(true);
connect(process, &QtcProcess::done, this, [this, process, node] { connect(process, &QtcProcess::done, this, [this, process, node] {
process->deleteLater(); process->deleteLater();
if (process->result() != ProcessResult::FinishedWithSuccess) if (process->result() != ProcessResult::FinishedWithSuccess)

View File

@@ -213,6 +213,7 @@ void ChangeSelectionDialog::recalculateCompletion()
process->setEnvironment(client->processEnvironment()); process->setEnvironment(client->processEnvironment());
process->setCommand({client->vcsBinary(), {"for-each-ref", "--format=%(refname:short)"}}); process->setCommand({client->vcsBinary(), {"for-each-ref", "--format=%(refname:short)"}});
process->setWorkingDirectory(workingDir); process->setWorkingDirectory(workingDir);
process->setUseCtrlCStub(true);
connect(process, &QtcProcess::done, this, [this, process] { connect(process, &QtcProcess::done, this, [this, process] {
if (process->result() == ProcessResult::FinishedWithSuccess) if (process->result() == ProcessResult::FinishedWithSuccess)
m_changeModel->setStringList(process->cleanedStdOut().split('\n')); m_changeModel->setStringList(process->cleanedStdOut().split('\n'));

View File

@@ -248,6 +248,7 @@ QueryContext::QueryContext(const QString &query,
QObject *parent) QObject *parent)
: QObject(parent) : QObject(parent)
{ {
m_process.setUseCtrlCStub(true);
if (server.type == GerritServer::Ssh) { if (server.type == GerritServer::Ssh) {
m_binary = p->ssh; m_binary = p->ssh;
if (server.port) if (server.port)

View File

@@ -119,6 +119,7 @@ FetchContext::FetchContext(const QSharedPointer<GerritChange> &change,
, m_server(server) , m_server(server)
, m_state(FetchState) , m_state(FetchState)
{ {
m_process.setUseCtrlCStub(true);
connect(&m_process, &QtcProcess::done, this, &FetchContext::processDone); connect(&m_process, &QtcProcess::done, this, &FetchContext::processDone);
connect(&m_process, &QtcProcess::readyReadStandardError, connect(&m_process, &QtcProcess::readyReadStandardError,
this, &FetchContext::processReadyReadStandardError); this, &FetchContext::processReadyReadStandardError);

View File

@@ -114,6 +114,7 @@ void VcsCommandPrivate::setupProcess(QtcProcess *process, const Job &job)
process->setProcessChannelMode(QProcess::MergedChannels); process->setProcessChannelMode(QProcess::MergedChannels);
if (m_codec) if (m_codec)
process->setCodec(m_codec); process->setCodec(m_codec);
process->setUseCtrlCStub(true);
installStdCallbacks(process); installStdCallbacks(process);