Mercurial > hg > toybox
comparison 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 |
comparison
equal
deleted
inserted
replaced
695:d2dde3d0ef05 | 696:99ca30ad3d2b |
---|---|
59 | 59 |
60 va_start(va, msg); | 60 va_start(va, msg); |
61 verror_msg(msg, 0, va); | 61 verror_msg(msg, 0, va); |
62 va_end(va); | 62 va_end(va); |
63 | 63 |
64 exit(!toys.exitval ? 1 : toys.exitval); | 64 if (!toys.exitval) toys.exitval++; |
65 if (toys.rebound) longjmp(*toys.rebound, 1); | |
66 else exit(toys.exitval); | |
65 } | 67 } |
66 | 68 |
67 | 69 |
68 // Die with an error message and strerror(errno) | 70 // Die with an error message and strerror(errno) |
69 void perror_exit(char *msg, ...) | 71 void perror_exit(char *msg, ...) |
72 | 74 |
73 va_start(va, msg); | 75 va_start(va, msg); |
74 verror_msg(msg, errno, va); | 76 verror_msg(msg, errno, va); |
75 va_end(va); | 77 va_end(va); |
76 | 78 |
77 exit(!toys.exitval ? 1 : toys.exitval); | 79 if (!toys.exitval) toys.exitval++; |
80 if (toys.rebound) longjmp(*toys.rebound, 1); | |
81 else exit(toys.exitval); | |
78 } | 82 } |
79 | 83 |
80 // Die unless we can allocate memory. | 84 // Die unless we can allocate memory. |
81 void *xmalloc(size_t size) | 85 void *xmalloc(size_t size) |
82 { | 86 { |