hush: stop ignoring ^Z in child shells
This commit is contained in:
parent
c4ada79343
commit
74a931ac9e
27
shell/hush.c
27
shell/hush.c
@ -2276,15 +2276,28 @@ void re_execute_shell(char ***to_free, const char *s, char *argv0, char **argv);
|
|||||||
|
|
||||||
static void reset_traps_to_defaults(void)
|
static void reset_traps_to_defaults(void)
|
||||||
{
|
{
|
||||||
|
enum {
|
||||||
|
JOBSIGS = (1 << SIGTTIN) | (1 << SIGTTOU) | (1 << SIGTSTP)
|
||||||
|
};
|
||||||
unsigned sig;
|
unsigned sig;
|
||||||
int dirty;
|
|
||||||
|
|
||||||
if (!G.traps)
|
if (!G.traps && !(G.non_DFL_mask & JOBSIGS))
|
||||||
return;
|
return;
|
||||||
dirty = 0;
|
|
||||||
for (sig = 0; sig < NSIG; sig++) {
|
/* This function is always called in a child shell.
|
||||||
if (!G.traps[sig])
|
* Child shells are not interactive.
|
||||||
|
* SIGTTIN/SIGTTOU/SIGTSTP should not have special handling.
|
||||||
|
* Testcase: (while :; do :; done) + ^Z should background.
|
||||||
|
*/
|
||||||
|
G.non_DFL_mask &= ~JOBSIGS;
|
||||||
|
sigdelset(&G.blocked_set, SIGTTIN);
|
||||||
|
sigdelset(&G.blocked_set, SIGTTOU);
|
||||||
|
sigdelset(&G.blocked_set, SIGTSTP);
|
||||||
|
|
||||||
|
if (G.traps) for (sig = 0; sig < NSIG; sig++) {
|
||||||
|
if (!G.traps[sig]) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
free(G.traps[sig]);
|
free(G.traps[sig]);
|
||||||
G.traps[sig] = NULL;
|
G.traps[sig] = NULL;
|
||||||
/* There is no signal for 0 (EXIT) */
|
/* There is no signal for 0 (EXIT) */
|
||||||
@ -2296,10 +2309,8 @@ static void reset_traps_to_defaults(void)
|
|||||||
if (sig < 32 && (G.non_DFL_mask & (1 << sig)))
|
if (sig < 32 && (G.non_DFL_mask & (1 << sig)))
|
||||||
continue;
|
continue;
|
||||||
sigdelset(&G.blocked_set, sig);
|
sigdelset(&G.blocked_set, sig);
|
||||||
dirty = 1;
|
|
||||||
}
|
}
|
||||||
if (dirty)
|
sigprocmask(SIG_SETMASK, &G.blocked_set, NULL);
|
||||||
sigprocmask(SIG_SETMASK, &G.blocked_set, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !BB_MMU */
|
#else /* !BB_MMU */
|
||||||
|
Loading…
Reference in New Issue
Block a user