Basic ^C interrupt implementation.

For testing, I made cat put itself into a new process group.
This should eventually be done by sh between fork() and exec().
This commit is contained in:
Andreas Kling 2018-11-02 14:06:48 +01:00
commit 10b666f69a
Notes: sideshowbarker 2024-07-19 18:34:25 +09:00
11 changed files with 94 additions and 38 deletions

View file

@ -157,7 +157,14 @@ static int runcmd(char* cmd)
//printf("Exited normally with status %d\n", WEXITSTATUS(wstatus));
} else {
if (WIFSIGNALED(wstatus)) {
printf("Terminated by signal %d\n", WTERMSIG(wstatus));
switch (WTERMSIG(wstatus)) {
case SIGINT:
printf("Interrupted\n");
break;
default:
printf("Terminated by signal %d\n", WTERMSIG(wstatus));
break;
}
} else {
printf("Exited abnormally\n");
}