From 69fc91d9744963752aaa7e73174ea49f60353aeb Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Mon, 10 Aug 2020 22:58:21 +0430 Subject: [PATCH] Shell: Cancel a running for loop upon receiving any non-SIGINT signal And keep the old behaviour of needing two interruptions on SIGINT. --- Shell/AST.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Shell/AST.cpp b/Shell/AST.cpp index 64a9ef86ca..be8d600d69 100644 --- a/Shell/AST.cpp +++ b/Shell/AST.cpp @@ -777,13 +777,15 @@ RefPtr ForLoop::run(RefPtr shell) if (!job || job->is_running_in_background()) continue; shell->block_on_job(job); - if (job->signaled() - && (job->termination_signal() == SIGINT - || job->termination_signal() == SIGKILL - || job->termination_signal() == SIGQUIT)) - ++consecutive_interruptions; - else + + if (job->signaled()) { + if (job->termination_signal() == SIGINT) + ++consecutive_interruptions; + else + break; + } else { consecutive_interruptions = 0; + } } }