aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2025-08-03 00:44:32 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-08-03 00:44:32 +0200
commite591316e020258d07dc987c5f2f4b7a03d786ddd (patch)
tree2ca548f7cfacf20f08816242213c60c0816e9b28
parent7d782e8813d1c3e7c9a96371ec37aaef1da08da9 (diff)
downloadbusybox-w32-e591316e020258d07dc987c5f2f4b7a03d786ddd.tar.gz
busybox-w32-e591316e020258d07dc987c5f2f4b7a03d786ddd.tar.bz2
busybox-w32-e591316e020258d07dc987c5f2f4b7a03d786ddd.zip
hush: rename hush_exit to save_history_run_exit_trap_and_exit, sigexit to restore_ttypgrp_and_killsig_or__exit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/shell/hush.c b/shell/hush.c
index d1f687f9d..5707b4b31 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -1929,7 +1929,7 @@ static void restore_G_args(save_arg_t *sv, char **argv)
1929 * "trap - SIGxxx": 1929 * "trap - SIGxxx":
1930 * if sig is in special_sig_mask, set handler back to: 1930 * if sig is in special_sig_mask, set handler back to:
1931 * record_pending_signo, or to IGN if it's a tty stop signal 1931 * record_pending_signo, or to IGN if it's a tty stop signal
1932 * if sig is in fatal_sig_mask, set handler back to sigexit. 1932 * if sig is in fatal_sig_mask, set handler back to restore_ttypgrp_and_killsig_or__exit.
1933 * else: set handler back to SIG_DFL 1933 * else: set handler back to SIG_DFL
1934 * "trap 'cmd' SIGxxx": 1934 * "trap 'cmd' SIGxxx":
1935 * set handler to record_pending_signo. 1935 * set handler to record_pending_signo.
@@ -2002,7 +2002,7 @@ static sighandler_t install_sighandler(int sig, sighandler_t handler)
2002 return old_sa.sa_handler; 2002 return old_sa.sa_handler;
2003} 2003}
2004 2004
2005static void hush_exit(int exitcode) NORETURN; 2005static void save_history_run_exit_trap_and_exit(int exitcode) NORETURN;
2006 2006
2007static void restore_ttypgrp_and__exit(void) NORETURN; 2007static void restore_ttypgrp_and__exit(void) NORETURN;
2008static void restore_ttypgrp_and__exit(void) 2008static void restore_ttypgrp_and__exit(void)
@@ -2010,7 +2010,7 @@ static void restore_ttypgrp_and__exit(void)
2010 /* xfunc has failed! die die die */ 2010 /* xfunc has failed! die die die */
2011 /* no EXIT traps, this is an escape hatch! */ 2011 /* no EXIT traps, this is an escape hatch! */
2012 G.exiting = 1; 2012 G.exiting = 1;
2013 hush_exit(xfunc_error_retval); 2013 save_history_run_exit_trap_and_exit(xfunc_error_retval);
2014} 2014}
2015 2015
2016#if ENABLE_HUSH_JOB 2016#if ENABLE_HUSH_JOB
@@ -2046,8 +2046,8 @@ static void fflush_and__exit(void)
2046 * or called directly with -EXITCODE. 2046 * or called directly with -EXITCODE.
2047 * We also call it if xfunc is exiting. 2047 * We also call it if xfunc is exiting.
2048 */ 2048 */
2049static void sigexit(int sig) NORETURN; 2049static void restore_ttypgrp_and_killsig_or__exit(int sig) NORETURN;
2050static void sigexit(int sig) 2050static void restore_ttypgrp_and_killsig_or__exit(int sig)
2051{ 2051{
2052 /* Careful: we can end up here after [v]fork. Do not restore 2052 /* Careful: we can end up here after [v]fork. Do not restore
2053 * tty pgrp then, only top-level shell process does that */ 2053 * tty pgrp then, only top-level shell process does that */
@@ -2081,7 +2081,7 @@ static sighandler_t pick_sighandler(unsigned sig)
2081#if ENABLE_HUSH_JOB 2081#if ENABLE_HUSH_JOB
2082 /* is sig fatal? */ 2082 /* is sig fatal? */
2083 if (G_fatal_sig_mask & sigmask) 2083 if (G_fatal_sig_mask & sigmask)
2084 handler = sigexit; 2084 handler = restore_ttypgrp_and_killsig_or__exit;
2085 else 2085 else
2086#endif 2086#endif
2087 /* sig has special handling? */ 2087 /* sig has special handling? */
@@ -2102,7 +2102,7 @@ static sighandler_t pick_sighandler(unsigned sig)
2102static const char* FAST_FUNC get_local_var_value(const char *name); 2102static const char* FAST_FUNC get_local_var_value(const char *name);
2103 2103
2104/* Restores tty foreground process group, and exits. */ 2104/* Restores tty foreground process group, and exits. */
2105static void hush_exit(int exitcode) 2105static void save_history_run_exit_trap_and_exit(int exitcode)
2106{ 2106{
2107#if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT 2107#if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT
2108 if (G.line_input_state) { 2108 if (G.line_input_state) {
@@ -2155,7 +2155,7 @@ static void hush_exit(int exitcode)
2155 2155
2156 fflush_all(); 2156 fflush_all();
2157#if ENABLE_HUSH_JOB 2157#if ENABLE_HUSH_JOB
2158 sigexit(- (exitcode & 0xff)); 2158 restore_ttypgrp_and_killsig_or__exit(- (exitcode & 0xff));
2159#else 2159#else
2160 _exit(exitcode); 2160 _exit(exitcode);
2161#endif 2161#endif
@@ -2240,7 +2240,7 @@ static int check_and_run_traps(void)
2240 } 2240 }
2241 } 2241 }
2242 /* this restores tty pgrp, then kills us with SIGHUP */ 2242 /* this restores tty pgrp, then kills us with SIGHUP */
2243 sigexit(SIGHUP); 2243 restore_ttypgrp_and_killsig_or__exit(SIGHUP);
2244 } 2244 }
2245#endif 2245#endif
2246#if ENABLE_HUSH_FAST 2246#if ENABLE_HUSH_FAST
@@ -10144,7 +10144,7 @@ static int run_list(struct pipe *pi)
10144 if (rcode != 0 && G.o_opt[OPT_O_ERREXIT]) { 10144 if (rcode != 0 && G.o_opt[OPT_O_ERREXIT]) {
10145 debug_printf_exec("ERREXIT:1 errexit_depth:%d\n", G.errexit_depth); 10145 debug_printf_exec("ERREXIT:1 errexit_depth:%d\n", G.errexit_depth);
10146 if (G.errexit_depth == 0) 10146 if (G.errexit_depth == 0)
10147 hush_exit(rcode); 10147 save_history_run_exit_trap_and_exit(rcode);
10148 } 10148 }
10149 G.errexit_depth = sv_errexit_depth; 10149 G.errexit_depth = sv_errexit_depth;
10150 10150
@@ -10905,7 +10905,7 @@ int hush_main(int argc, char **argv)
10905 parse_and_run_file(hfopen(NULL)); /* stdin */ 10905 parse_and_run_file(hfopen(NULL)); /* stdin */
10906 10906
10907 final_return: 10907 final_return:
10908 hush_exit(G.last_exitcode); 10908 save_history_run_exit_trap_and_exit(G.last_exitcode);
10909} 10909}
10910 10910
10911/* 10911/*
@@ -11091,19 +11091,19 @@ static int FAST_FUNC builtin_exit(char **argv)
11091 * TODO: we can use G.exiting = -1 as indicator "last cmd was exit" 11091 * TODO: we can use G.exiting = -1 as indicator "last cmd was exit"
11092 */ 11092 */
11093 11093
11094 /* note: EXIT trap is run by hush_exit */ 11094 /* note: EXIT trap is run by save_history_run_exit_trap_and_exit */
11095 argv = skip_dash_dash(argv); 11095 argv = skip_dash_dash(argv);
11096 if (argv[0] == NULL) { 11096 if (argv[0] == NULL) {
11097#if ENABLE_HUSH_TRAP 11097#if ENABLE_HUSH_TRAP
11098 if (G.pre_trap_exitcode >= 0) /* "exit" in trap uses $? from before the trap */ 11098 if (G.pre_trap_exitcode >= 0) /* "exit" in trap uses $? from before the trap */
11099 hush_exit(G.pre_trap_exitcode); 11099 save_history_run_exit_trap_and_exit(G.pre_trap_exitcode);
11100#endif 11100#endif
11101 hush_exit(G.last_exitcode); 11101 save_history_run_exit_trap_and_exit(G.last_exitcode);
11102 } 11102 }
11103 /* mimic bash: exit 123abc == exit 255 + error msg */ 11103 /* mimic bash: exit 123abc == exit 255 + error msg */
11104 xfunc_error_retval = 255; 11104 xfunc_error_retval = 255;
11105 /* bash: exit -2 == exit 254, no error msg */ 11105 /* bash: exit -2 == exit 254, no error msg */
11106 hush_exit(xatoi(argv[0]) & 0xff); 11106 save_history_run_exit_trap_and_exit(xatoi(argv[0]) & 0xff);
11107} 11107}
11108 11108
11109#if ENABLE_HUSH_TYPE 11109#if ENABLE_HUSH_TYPE