From 5ae2f6e9ec077432dc56d5cb8fc5c26c5cca8517 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sat, 8 Aug 2020 13:48:07 +0430 Subject: Shell: Stop a for loop upon receiving two consecutive interruptions This does not work perfectly (just like every other shell...), if the running program handles the signal (SIGINT in this case) and quits cleanly, the shell cannot detect the interruption. This is the case with our `sleep(1)`. --- Shell/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Shell/main.cpp') diff --git a/Shell/main.cpp b/Shell/main.cpp index 6c279ba488..80ef3aa22d 100644 --- a/Shell/main.cpp +++ b/Shell/main.cpp @@ -105,10 +105,10 @@ int main(int argc, char** argv) } #endif if (child_pid == job.pid()) { - if (WIFEXITED(wstatus)) { + if (WIFSIGNALED(wstatus) && !WIFSTOPPED(wstatus)) { + job.set_signalled(WTERMSIG(wstatus)); + } else if (WIFEXITED(wstatus)) { job.set_has_exit(WEXITSTATUS(wstatus)); - } else if (WIFSIGNALED(wstatus) && !WIFSTOPPED(wstatus)) { - job.set_has_exit(126); } else if (WIFSTOPPED(wstatus)) { job.unblock(); job.set_is_suspended(true); -- cgit v1.2.3