From 558303076c494519a2d4a1212f0a60e011662f42 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 16 Jun 2013 19:59:51 -0500 Subject: Add xexit() and make error_exit() use it. --- lib/lib.c | 12 ++++++++---- lib/lib.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/lib.c b/lib/lib.c index af820e22..dca92cbe 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -17,6 +17,12 @@ void xstrncpy(char *dest, char *src, size_t size) 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 @@ void error_exit(char *msg, ...) verror_msg(msg, 0, va); va_end(va); - if (toys.rebound) longjmp(*toys.rebound, 1); - else exit(toys.exitval); + xexit(); } @@ -72,8 +77,7 @@ void perror_exit(char *msg, ...) 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 --git a/lib/lib.h b/lib/lib.h index 131f9c44..70f8f493 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -87,6 +87,7 @@ void show_help(void); // 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, ...); -- cgit v1.2.3