diff options
author | Denys Vlasenko | 2023-01-30 15:57:04 +0100 |
---|---|---|
committer | Denys Vlasenko | 2023-01-30 15:57:04 +0100 |
commit | 6101b6d3eaa0fe5096c43d4fc648d49a532ee9c0 (patch) | |
tree | 72cf3a66017af2f324eecc3e1d3512e0e5070858 | |
parent | 93e0898c663a533082b5f3c2e7dcce93ec47076d (diff) | |
download | busybox-6101b6d3eaa0fe5096c43d4fc648d49a532ee9c0.zip busybox-6101b6d3eaa0fe5096c43d4fc648d49a532ee9c0.tar.gz |
hush: remove special handling of SIGHUP
Kernel should do the right thing.
(ash and dash do not have special SIGHUP handling.)
function old new delta
check_and_run_traps 278 214 -64
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/shell/hush.c b/shell/hush.c index f064b8f..9b87e28 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -1830,6 +1830,8 @@ static void restore_G_args(save_arg_t *sv, char **argv) * SIGTERM (interactive): ignore * SIGHUP (interactive): * send SIGCONT to stopped jobs, send SIGHUP to all jobs and exit +//HUP: we don't need to do this, kernel does this for us +//HUP: ("orphaned process group" handling according to POSIX) * SIGTTIN, SIGTTOU, SIGTSTP (if job control is on): ignore * Note that ^Z is handled not by trapping SIGTSTP, but by seeing * that all pipe members are stopped. Try this in bash: @@ -1931,7 +1933,7 @@ enum { SPECIAL_INTERACTIVE_SIGS = 0 | (1 << SIGTERM) | (1 << SIGINT) - | (1 << SIGHUP) +//HUP | (1 << SIGHUP) , SPECIAL_JOBSTOP_SIGS = 0 #if ENABLE_HUSH_JOB @@ -2177,23 +2179,23 @@ static int check_and_run_traps(void) last_sig = sig; break; #if ENABLE_HUSH_JOB - case SIGHUP: { -//TODO: why are we doing this? ash and dash don't do this, -//they have no handler for SIGHUP at all, -//they rely on kernel to send SIGHUP+SIGCONT to orphaned process groups - struct pipe *job; - debug_printf_exec("%s: sig:%d default SIGHUP handler\n", __func__, sig); - /* bash is observed to signal whole process groups, - * not individual processes */ - for (job = G.job_list; job; job = job->next) { - if (job->pgrp <= 0) - continue; - debug_printf_exec("HUPing pgrp %d\n", job->pgrp); - if (kill(- job->pgrp, SIGHUP) == 0) - kill(- job->pgrp, SIGCONT); - } - sigexit(SIGHUP); - } +//HUP case SIGHUP: { +//HUP//TODO: why are we doing this? ash and dash don't do this, +//HUP//they have no handler for SIGHUP at all, +//HUP//they rely on kernel to send SIGHUP+SIGCONT to orphaned process groups +//HUP struct pipe *job; +//HUP debug_printf_exec("%s: sig:%d default SIGHUP handler\n", __func__, sig); +//HUP /* bash is observed to signal whole process groups, +//HUP * not individual processes */ +//HUP for (job = G.job_list; job; job = job->next) { +//HUP if (job->pgrp <= 0) +//HUP continue; +//HUP debug_printf_exec("HUPing pgrp %d\n", job->pgrp); +//HUP if (kill(- job->pgrp, SIGHUP) == 0) +//HUP kill(- job->pgrp, SIGCONT); +//HUP } +//HUP sigexit(SIGHUP); +//HUP } #endif #if ENABLE_HUSH_FAST case SIGCHLD: |