aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-11-16 00:35:46 -0600
committerRob Landley <rob@landley.net>2012-11-16 00:35:46 -0600
commitcaf39c26827f355c4e107f55c5c51f67c484bfd7 (patch)
tree718852f37b7143cb63e6e8838093993b19391a39 /lib/lib.c
parent02261e8082b9b098b20a4291fc2583f3c41db8d2 (diff)
downloadtoybox-caf39c26827f355c4e107f55c5c51f67c484bfd7.tar.gz
Add rebound support to intercept error_exit() and longjmp instead.
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 06828a40..18578815 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -61,7 +61,9 @@ void error_exit(char *msg, ...)
verror_msg(msg, 0, va);
va_end(va);
- exit(!toys.exitval ? 1 : toys.exitval);
+ if (!toys.exitval) toys.exitval++;
+ if (toys.rebound) longjmp(*toys.rebound, 1);
+ else exit(toys.exitval);
}
@@ -74,7 +76,9 @@ void perror_exit(char *msg, ...)
verror_msg(msg, errno, va);
va_end(va);
- exit(!toys.exitval ? 1 : toys.exitval);
+ if (!toys.exitval) toys.exitval++;
+ if (toys.rebound) longjmp(*toys.rebound, 1);
+ else exit(toys.exitval);
}
// Die unless we can allocate memory.