1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:58:11 +00:00

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)`.
This commit is contained in:
AnotherTest 2020-08-08 13:48:07 +04:30 committed by Andreas Kling
parent c81c8b68bb
commit 5ae2f6e9ec
3 changed files with 38 additions and 4 deletions

View file

@ -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);