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>
This commit is contained in:
@@ -7,34 +7,16 @@
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
/* Keeping it separate allows to NOT suck in stdio for VERY small applets.
|
||||
/* Keeping it separate allows to NOT pull in stdio for VERY small applets.
|
||||
* Try building busybox with only "true" enabled... */
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
int die_sleep;
|
||||
#if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_HUSH
|
||||
jmp_buf die_jmp;
|
||||
#endif
|
||||
void (*die_func)(void);
|
||||
|
||||
void FAST_FUNC xfunc_die(void)
|
||||
{
|
||||
if (die_sleep) {
|
||||
if ((ENABLE_FEATURE_PREFER_APPLETS || ENABLE_HUSH)
|
||||
&& die_sleep < 0
|
||||
) {
|
||||
/* Special case. We arrive here if NOFORK applet
|
||||
* calls xfunc, which then decides to die.
|
||||
* We don't die, but jump instead back to caller.
|
||||
* NOFORK applets still cannot carelessly call xfuncs:
|
||||
* p = xmalloc(10);
|
||||
* q = xmalloc(10); // BUG! if this dies, we leak p!
|
||||
*/
|
||||
/* -2222 means "zero" (longjmp can't pass 0)
|
||||
* run_nofork_applet() catches -2222. */
|
||||
longjmp(die_jmp, xfunc_error_retval ? xfunc_error_retval : -2222);
|
||||
}
|
||||
sleep(die_sleep);
|
||||
}
|
||||
if (die_func)
|
||||
die_func();
|
||||
exit(xfunc_error_retval);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user