diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-08-08 13:48:07 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-09 21:08:07 +0200 |
commit | 5ae2f6e9ec077432dc56d5cb8fc5c26c5cca8517 (patch) | |
tree | 4b388dc3e4c7a76175b5484c23c64ecc8e9056b8 /Shell/main.cpp | |
parent | c81c8b68bb7a0b8aa6989d505002fa697014919b (diff) | |
download | serenity-5ae2f6e9ec077432dc56d5cb8fc5c26c5cca8517.zip |
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)`.
Diffstat (limited to 'Shell/main.cpp')
-rw-r--r-- | Shell/main.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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); |