esh: exit subshells on SIGINT
This commit is contained in:
parent
e3d7719883
commit
f22f4556c2
13
apps/sh.c
13
apps/sh.c
@ -352,8 +352,13 @@ hashmap_t * job_hash = NULL;
|
|||||||
|
|
||||||
void sig_break_loop(int sig) {
|
void sig_break_loop(int sig) {
|
||||||
/* Interrupt handler */
|
/* Interrupt handler */
|
||||||
break_while = sig;
|
if ((shell_interactive == 1 && !is_subshell)) {
|
||||||
signal(sig, sig_break_loop);
|
break_while = sig;
|
||||||
|
signal(sig, sig_break_loop);
|
||||||
|
} else {
|
||||||
|
signal(sig, SIG_DFL);
|
||||||
|
raise(sig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void redraw_prompt_func(rline_context_t * context) {
|
void redraw_prompt_func(rline_context_t * context) {
|
||||||
@ -1854,6 +1859,10 @@ uint32_t shell_cmd_while(int argc, char * argv[]) {
|
|||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
pid = waitpid(child_pid, &ret_code, 0);
|
pid = waitpid(child_pid, &ret_code, 0);
|
||||||
|
if (pid != -1 && WIFSIGNALED(ret_code)) {
|
||||||
|
int sig = WTERMSIG(ret_code);
|
||||||
|
if (sig == SIGINT) return 127; /* break */
|
||||||
|
}
|
||||||
} while (pid != -1 || (pid == -1 && errno != ECHILD));
|
} while (pid != -1 || (pid == -1 && errno != ECHILD));
|
||||||
} else {
|
} else {
|
||||||
reset_pgrp();
|
reset_pgrp();
|
||||||
|
Loading…
Reference in New Issue
Block a user