diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-01-30 15:57:04 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-01-30 15:57:04 +0100 |
commit | 6101b6d3eaa0fe5096c43d4fc648d49a532ee9c0 (patch) | |
tree | 72cf3a66017af2f324eecc3e1d3512e0e5070858 | |
parent | 93e0898c663a533082b5f3c2e7dcce93ec47076d (diff) | |
download | busybox-w32-6101b6d3eaa0fe5096c43d4fc648d49a532ee9c0.tar.gz busybox-w32-6101b6d3eaa0fe5096c43d4fc648d49a532ee9c0.tar.bz2 busybox-w32-6101b6d3eaa0fe5096c43d4fc648d49a532ee9c0.zip |
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 f064b8fd2..9b87e28cf 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -1830,6 +1830,8 @@ static void restore_G_args(save_arg_t *sv, char **argv) | |||
1830 | * SIGTERM (interactive): ignore | 1830 | * SIGTERM (interactive): ignore |
1831 | * SIGHUP (interactive): | 1831 | * SIGHUP (interactive): |
1832 | * send SIGCONT to stopped jobs, send SIGHUP to all jobs and exit | 1832 | * send SIGCONT to stopped jobs, send SIGHUP to all jobs and exit |
1833 | //HUP: we don't need to do this, kernel does this for us | ||
1834 | //HUP: ("orphaned process group" handling according to POSIX) | ||
1833 | * SIGTTIN, SIGTTOU, SIGTSTP (if job control is on): ignore | 1835 | * SIGTTIN, SIGTTOU, SIGTSTP (if job control is on): ignore |
1834 | * Note that ^Z is handled not by trapping SIGTSTP, but by seeing | 1836 | * Note that ^Z is handled not by trapping SIGTSTP, but by seeing |
1835 | * that all pipe members are stopped. Try this in bash: | 1837 | * that all pipe members are stopped. Try this in bash: |
@@ -1931,7 +1933,7 @@ enum { | |||
1931 | SPECIAL_INTERACTIVE_SIGS = 0 | 1933 | SPECIAL_INTERACTIVE_SIGS = 0 |
1932 | | (1 << SIGTERM) | 1934 | | (1 << SIGTERM) |
1933 | | (1 << SIGINT) | 1935 | | (1 << SIGINT) |
1934 | | (1 << SIGHUP) | 1936 | //HUP | (1 << SIGHUP) |
1935 | , | 1937 | , |
1936 | SPECIAL_JOBSTOP_SIGS = 0 | 1938 | SPECIAL_JOBSTOP_SIGS = 0 |
1937 | #if ENABLE_HUSH_JOB | 1939 | #if ENABLE_HUSH_JOB |
@@ -2177,23 +2179,23 @@ static int check_and_run_traps(void) | |||
2177 | last_sig = sig; | 2179 | last_sig = sig; |
2178 | break; | 2180 | break; |
2179 | #if ENABLE_HUSH_JOB | 2181 | #if ENABLE_HUSH_JOB |
2180 | case SIGHUP: { | 2182 | //HUP case SIGHUP: { |
2181 | //TODO: why are we doing this? ash and dash don't do this, | 2183 | //HUP//TODO: why are we doing this? ash and dash don't do this, |
2182 | //they have no handler for SIGHUP at all, | 2184 | //HUP//they have no handler for SIGHUP at all, |
2183 | //they rely on kernel to send SIGHUP+SIGCONT to orphaned process groups | 2185 | //HUP//they rely on kernel to send SIGHUP+SIGCONT to orphaned process groups |
2184 | struct pipe *job; | 2186 | //HUP struct pipe *job; |
2185 | debug_printf_exec("%s: sig:%d default SIGHUP handler\n", __func__, sig); | 2187 | //HUP debug_printf_exec("%s: sig:%d default SIGHUP handler\n", __func__, sig); |
2186 | /* bash is observed to signal whole process groups, | 2188 | //HUP /* bash is observed to signal whole process groups, |
2187 | * not individual processes */ | 2189 | //HUP * not individual processes */ |
2188 | for (job = G.job_list; job; job = job->next) { | 2190 | //HUP for (job = G.job_list; job; job = job->next) { |
2189 | if (job->pgrp <= 0) | 2191 | //HUP if (job->pgrp <= 0) |
2190 | continue; | 2192 | //HUP continue; |
2191 | debug_printf_exec("HUPing pgrp %d\n", job->pgrp); | 2193 | //HUP debug_printf_exec("HUPing pgrp %d\n", job->pgrp); |
2192 | if (kill(- job->pgrp, SIGHUP) == 0) | 2194 | //HUP if (kill(- job->pgrp, SIGHUP) == 0) |
2193 | kill(- job->pgrp, SIGCONT); | 2195 | //HUP kill(- job->pgrp, SIGCONT); |
2194 | } | 2196 | //HUP } |
2195 | sigexit(SIGHUP); | 2197 | //HUP sigexit(SIGHUP); |
2196 | } | 2198 | //HUP } |
2197 | #endif | 2199 | #endif |
2198 | #if ENABLE_HUSH_FAST | 2200 | #if ENABLE_HUSH_FAST |
2199 | case SIGCHLD: | 2201 | case SIGCHLD: |