[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox-cvs
Subject:    [git commit] hush: remove special handling of SIGHUP
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2023-01-30 14:57:04
Message-ID: 20230130145825.23A96820FD () busybox ! osuosl ! org
[Download RAW message or body]

commit: https://git.busybox.net/busybox/commit/?id=6101b6d3eaa0fe5096c43d4fc648d49a532ee9c0
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

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>
---
 shell/hush.c | 38 ++++++++++++++++++++------------------
 1 file 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)
  * 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:
_______________________________________________
busybox-cvs mailing list
busybox-cvs@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic