diff lib/lib.c @ 696:99ca30ad3d2b

Add rebound support to intercept error_exit() and longjmp instead.
author Rob Landley <rob@landley.net>
date Fri, 16 Nov 2012 00:35:46 -0600
parents 786841fdb1e0
children 078138791b5c
line wrap: on
line diff
--- a/lib/lib.c	Thu Nov 15 16:15:51 2012 -0600
+++ b/lib/lib.c	Fri Nov 16 00:35:46 2012 -0600
@@ -61,7 +61,9 @@
   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 @@
   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.