From caf39c26827f355c4e107f55c5c51f67c484bfd7 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 16 Nov 2012 00:35:46 -0600 Subject: Add rebound support to intercept error_exit() and longjmp instead. --- lib/lib.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') 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. -- cgit v1.2.3