diff options
author | Matt Kraai | 2000-10-25 15:10:08 +0000 |
---|---|---|
committer | Matt Kraai | 2000-10-25 15:10:08 +0000 |
commit | 324a778f31ac99f2c9d947a99dc4c37902bde6fe (patch) | |
tree | 137420d5835bb40bc9712e895da5377c664bd4b3 /utility.c | |
parent | b60208dd8fe3328a5db8be1dc958e62c9898a73b (diff) | |
download | busybox-324a778f31ac99f2c9d947a99dc4c37902bde6fe.zip busybox-324a778f31ac99f2c9d947a99dc4c37902bde6fe.tar.gz |
Added a fatalPerror function to simplify error handling.
Diffstat (limited to 'utility.c')
-rw-r--r-- | utility.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -109,6 +109,23 @@ extern void fatalError(const char *s, ...) exit(EXIT_FAILURE); } +extern void fatalPerror(const char *s, ...) +{ + va_list p; + + va_start(p, s); + fflush(stdout); + fprintf(stderr, "%s: ", applet_name); + if (s && *s) { + vfprintf(stderr, s, p); + fputs(": ", stderr); + } + fprintf(stderr, "%s\n", strerror(errno)); + va_end(p); + fflush(stderr); + exit(EXIT_FAILURE); +} + #if defined BB_INIT /* Returns kernel version encoded as major*65536 + minor*256 + patch, * so, for example, to check if the kernel is greater than 2.2.11: |