Alters the behavior of the 'Create NAT on tunnel' to also add the appropriate NAT...
[tomato.git] / release / src / router / busybox / libbb / xfunc_die.c
blob204e5e49da5e1e5174752c79da0cd351737c4d1a
1 /* vi: set sw=4 ts=4: */
2 /*
3 * Utility routines.
5 * Copyright (C) 2008 by Denys Vlasenko <vda.linux@googlemail.com>
7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */
10 /* Keeping it separate allows to NOT suck in stdio for VERY small applets.
11 * Try building busybox with only "true" enabled... */
13 #include "libbb.h"
15 int die_sleep;
16 #if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_HUSH
17 jmp_buf die_jmp;
18 #endif
20 void FAST_FUNC xfunc_die(void)
22 if (die_sleep) {
23 if ((ENABLE_FEATURE_PREFER_APPLETS || ENABLE_HUSH)
24 && die_sleep < 0
25 ) {
26 /* Special case. We arrive here if NOFORK applet
27 * calls xfunc, which then decides to die.
28 * We don't die, but jump instead back to caller.
29 * NOFORK applets still cannot carelessly call xfuncs:
30 * p = xmalloc(10);
31 * q = xmalloc(10); // BUG! if this dies, we leak p!
33 /* -2222 means "zero" (longjmp can't pass 0)
34 * run_nofork_applet() catches -2222. */
35 longjmp(die_jmp, xfunc_error_retval ? xfunc_error_retval : -2222);
37 sleep(die_sleep);
39 exit(xfunc_error_retval);