diff options
author | Denis Vlasenko | 2007-04-09 21:35:07 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-04-09 21:35:07 +0000 |
commit | 3f3aa2a57dc648ade9083f3b3ad83cce8206b912 (patch) | |
tree | d5c648f583bb2edef25f05c2bed303df3d1a61f6 /libbb/error_msg_and_die.c | |
parent | cd7001f7055c3fc2d6298ab9e3befe91e951c652 (diff) | |
download | busybox-3f3aa2a57dc648ade9083f3b3ad83cce8206b912.zip busybox-3f3aa2a57dc648ade9083f3b3ad83cce8206b912.tar.gz |
make xfunctions optionally longjump instead of exit.
use it for making NOFORK more practical.
touch: make it a NOFORK applet
Diffstat (limited to 'libbb/error_msg_and_die.c')
-rw-r--r-- | libbb/error_msg_and_die.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libbb/error_msg_and_die.c b/libbb/error_msg_and_die.c index 7c5a4eb..39178a3 100644 --- a/libbb/error_msg_and_die.c +++ b/libbb/error_msg_and_die.c @@ -7,18 +7,19 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <stdlib.h> #include "libbb.h" int die_sleep; +jmp_buf die_jmp; void sleep_and_die(void) { - if (die_sleep) + if (die_sleep) { + /* Special case: don't die, but jump */ + if (die_sleep < 0) + longjmp(die_jmp, xfunc_error_retval); sleep(die_sleep); + } exit(xfunc_error_retval); } |