# HG changeset patch # User Rob Landley # Date 1371430791 18000 # Node ID 07693eb46e267994684d7b336c077b7f8ba0705f # Parent b792de46d7151002ec5ec6c228cde8ee65886478 Add xexit() and make error_exit() use it. diff -r b792de46d715 -r 07693eb46e26 lib/lib.c --- a/lib/lib.c Sun Jun 16 16:37:43 2013 -0500 +++ b/lib/lib.c Sun Jun 16 19:59:51 2013 -0500 @@ -17,6 +17,12 @@ strcpy(dest, src); } +void xexit(void) +{ + if (toys.rebound) longjmp(*toys.rebound, 1); + else exit(toys.exitval); +} + void verror_msg(char *msg, int err, va_list va) { char *s = ": %s"; @@ -58,8 +64,7 @@ verror_msg(msg, 0, va); va_end(va); - if (toys.rebound) longjmp(*toys.rebound, 1); - else exit(toys.exitval); + xexit(); } @@ -72,8 +77,7 @@ verror_msg(msg, errno, va); va_end(va); - if (toys.rebound) longjmp(*toys.rebound, 1); - else exit(toys.exitval); + xexit(); } // Die unless we can allocate memory. diff -r b792de46d715 -r 07693eb46e26 lib/lib.h --- a/lib/lib.h Sun Jun 16 16:37:43 2013 -0500 +++ b/lib/lib.h Sun Jun 16 19:59:51 2013 -0500 @@ -87,6 +87,7 @@ // lib.c void xstrncpy(char *dest, char *src, size_t size); +void xexit(void) noreturn; void verror_msg(char *msg, int err, va_list va); void error_msg(char *msg, ...); void perror_msg(char *msg, ...);