aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-09 16:42:57 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-09 16:42:57 +0200
commit550bf5b4a418378cd8f9fbbf5252fe57acdacb5a (patch)
tree7ed13e04cf415be6830363953220d7cffd4580b8 /shell
parent4cd99e7c6c1af77721b890ed5ae26d747796c4bd (diff)
downloadbusybox-w32-550bf5b4a418378cd8f9fbbf5252fe57acdacb5a.tar.gz
busybox-w32-550bf5b4a418378cd8f9fbbf5252fe57acdacb5a.tar.bz2
busybox-w32-550bf5b4a418378cd8f9fbbf5252fe57acdacb5a.zip
remove global "jmp_buf die_jmp" from !FEATURE_PREFER_APPLETS builds
function old new delta xfunc_has_died - 21 +21 sleep_much - 12 +12 sleep10 - 9 +9 die_func - 4 +4 fflush_stdout_and_exit 35 36 +1 builtin_type 121 119 -2 die_sleep 4 - -4 xfunc_die 60 24 -36 hush_main 1128 1011 -117 die_jmp 156 - -156 ------------------------------------------------------------------------------ (add/remove: 4/2 grow/shrink: 1/3 up/down: 47/-315) Total: -268 bytes text data bss dec hex filename 939992 992 17652 958636 ea0ac busybox_old 939880 992 17496 958368 e9fa0 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/shell/hush.c b/shell/hush.c
index f085ed3eb..0d107715f 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -1479,10 +1479,11 @@ static sighandler_t install_sighandler(int sig, sighandler_t handler)
1479 1479
1480#if ENABLE_HUSH_JOB 1480#if ENABLE_HUSH_JOB
1481 1481
1482static void xfunc_has_died(void);
1482/* After [v]fork, in child: do not restore tty pgrp on xfunc death */ 1483/* After [v]fork, in child: do not restore tty pgrp on xfunc death */
1483# define disable_restore_tty_pgrp_on_exit() (die_sleep = 0) 1484# define disable_restore_tty_pgrp_on_exit() (die_func = NULL)
1484/* After [v]fork, in parent: restore tty pgrp on xfunc death */ 1485/* After [v]fork, in parent: restore tty pgrp on xfunc death */
1485# define enable_restore_tty_pgrp_on_exit() (die_sleep = -1) 1486# define enable_restore_tty_pgrp_on_exit() (die_func = xfunc_has_died)
1486 1487
1487/* Restores tty foreground process group, and exits. 1488/* Restores tty foreground process group, and exits.
1488 * May be called as signal handler for fatal signal 1489 * May be called as signal handler for fatal signal
@@ -1587,6 +1588,15 @@ static void hush_exit(int exitcode)
1587#endif 1588#endif
1588} 1589}
1589 1590
1591static void xfunc_has_died(void) NORETURN;
1592static void xfunc_has_died(void)
1593{
1594 /* xfunc has failed! die die die */
1595 /* no EXIT traps, this is an escape hatch! */
1596 G.exiting = 1;
1597 hush_exit(xfunc_error_retval);
1598}
1599
1590 1600
1591//TODO: return a mask of ALL handled sigs? 1601//TODO: return a mask of ALL handled sigs?
1592static int check_and_run_traps(void) 1602static int check_and_run_traps(void)
@@ -7866,12 +7876,7 @@ int hush_main(int argc, char **argv)
7866 /* Initialize some more globals to non-zero values */ 7876 /* Initialize some more globals to non-zero values */
7867 cmdedit_update_prompt(); 7877 cmdedit_update_prompt();
7868 7878
7869 if (setjmp(die_jmp)) { 7879 die_func = xfunc_has_died;
7870 /* xfunc has failed! die die die */
7871 /* no EXIT traps, this is an escape hatch! */
7872 G.exiting = 1;
7873 hush_exit(xfunc_error_retval);
7874 }
7875 7880
7876 /* Shell is non-interactive at first. We need to call 7881 /* Shell is non-interactive at first. We need to call
7877 * install_special_sighandlers() if we are going to execute "sh <script>", 7882 * install_special_sighandlers() if we are going to execute "sh <script>",
@@ -8129,9 +8134,7 @@ int hush_main(int argc, char **argv)
8129 /* Grab control of the terminal */ 8134 /* Grab control of the terminal */
8130 tcsetpgrp(G_interactive_fd, getpid()); 8135 tcsetpgrp(G_interactive_fd, getpid());
8131 } 8136 }
8132 /* -1 is special - makes xfuncs longjmp, not exit 8137 enable_restore_tty_pgrp_on_exit();
8133 * (we reset die_sleep = 0 whereever we [v]fork) */
8134 enable_restore_tty_pgrp_on_exit(); /* sets die_sleep = -1 */
8135 8138
8136# if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0 8139# if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0
8137 { 8140 {