diff --git a/bin/check/named-checkzone.c b/bin/check/named-checkzone.c index da909d67de..7ad917df9d 100644 --- a/bin/check/named-checkzone.c +++ b/bin/check/named-checkzone.c @@ -79,7 +79,7 @@ usage(void) { "%s zonename [ (filename|-) ]\n", prog_name, progmode == progmode_check ? "[-o filename]" : "-o filename"); - exit(1); + exit(EXIT_FAILURE); } static void @@ -206,7 +206,7 @@ main(int argc, char **argv) { } else { fprintf(stderr, "invalid argument to -i: %s\n", isc_commandline_argument); - exit(1); + exit(EXIT_FAILURE); } break; @@ -240,7 +240,7 @@ main(int argc, char **argv) { } else { fprintf(stderr, "invalid argument to -k: %s\n", isc_commandline_argument); - exit(1); + exit(EXIT_FAILURE); } break; @@ -251,7 +251,7 @@ main(int argc, char **argv) { if (*endp != '\0') { fprintf(stderr, "source serial number " "must be numeric"); - exit(1); + exit(EXIT_FAILURE); } break; @@ -262,7 +262,7 @@ main(int argc, char **argv) { if (*endp != '\0') { fprintf(stderr, "maximum TTL " "must be numeric"); - exit(1); + exit(EXIT_FAILURE); } break; @@ -279,7 +279,7 @@ main(int argc, char **argv) { } else { fprintf(stderr, "invalid argument to -n: %s\n", isc_commandline_argument); - exit(1); + exit(EXIT_FAILURE); } break; @@ -296,7 +296,7 @@ main(int argc, char **argv) { } else { fprintf(stderr, "invalid argument to -m: %s\n", isc_commandline_argument); - exit(1); + exit(EXIT_FAILURE); } break; @@ -321,7 +321,7 @@ main(int argc, char **argv) { } else { fprintf(stderr, "invalid argument to -r: %s\n", isc_commandline_argument); - exit(1); + exit(EXIT_FAILURE); } break; @@ -334,7 +334,7 @@ main(int argc, char **argv) { fprintf(stderr, "unknown or unsupported style: %s\n", isc_commandline_argument); - exit(1); + exit(EXIT_FAILURE); } break; @@ -344,7 +344,7 @@ main(int argc, char **argv) { fprintf(stderr, "isc_dir_chroot: %s: %s\n", isc_commandline_argument, isc_result_totext(result)); - exit(1); + exit(EXIT_FAILURE); } break; @@ -364,7 +364,7 @@ main(int argc, char **argv) { } else { fprintf(stderr, "invalid argument to -C: %s\n", isc_commandline_argument); - exit(1); + exit(EXIT_FAILURE); } break; @@ -385,7 +385,7 @@ main(int argc, char **argv) { } else { fprintf(stderr, "invalid argument to -M: %s\n", isc_commandline_argument); - exit(1); + exit(EXIT_FAILURE); } break; @@ -402,7 +402,7 @@ main(int argc, char **argv) { } else { fprintf(stderr, "invalid argument to -S: %s\n", isc_commandline_argument); - exit(1); + exit(EXIT_FAILURE); } break; @@ -414,7 +414,7 @@ main(int argc, char **argv) { } else { fprintf(stderr, "invalid argument to -T: %s\n", isc_commandline_argument); - exit(1); + exit(EXIT_FAILURE); } break; @@ -438,7 +438,7 @@ main(int argc, char **argv) { default: fprintf(stderr, "%s: unhandled option -%c\n", prog_name, isc_commandline_option); - exit(1); + exit(EXIT_FAILURE); } } @@ -447,7 +447,7 @@ main(int argc, char **argv) { if (result != ISC_R_SUCCESS) { fprintf(stderr, "isc_dir_chdir: %s: %s\n", workdir, isc_result_totext(result)); - exit(1); + exit(EXIT_FAILURE); } } @@ -463,7 +463,7 @@ main(int argc, char **argv) { } else { fprintf(stderr, "unknown file format: %s\n", inputformatstr); - exit(1); + exit(EXIT_FAILURE); } } @@ -481,12 +481,12 @@ main(int argc, char **argv) { rawversion > 1U) { fprintf(stderr, "unknown raw format version\n"); - exit(1); + exit(EXIT_FAILURE); } } else { fprintf(stderr, "unknown file format: %s\n", outputformatstr); - exit(1); + exit(EXIT_FAILURE); } } diff --git a/bin/confgen/util.c b/bin/confgen/util.c index 23b7f3fd57..9f65ac1ccc 100644 --- a/bin/confgen/util.c +++ b/bin/confgen/util.c @@ -13,14 +13,16 @@ /*! \file */ -#include "util.h" #include #include #include #include +#include #include +#include "util.h" + extern bool verbose; extern const char *progname; @@ -46,5 +48,5 @@ fatal(const char *format, ...) { va_end(args); fprintf(stderr, "\n"); isc__tls_setfatalmode(); - exit(1); + _exit(EXIT_FAILURE); } diff --git a/bin/delv/delv.c b/bin/delv/delv.c index 16e005ab7f..2d4de3d973 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -264,7 +264,7 @@ fatal(const char *format, ...) { va_end(args); fprintf(stderr, "\n"); isc__tls_setfatalmode(); - exit(1); + _exit(EXIT_FAILURE); } static void diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index a02b4cbff9..1f10437a41 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -359,8 +359,6 @@ get_reverse(char *reverse, size_t len, char *value, bool strict) { } } -void (*dighost_pre_exit_hook)(void) = NULL; - #if TARGET_OS_IPHONE void warn(const char *format, ...) { @@ -393,10 +391,7 @@ digexit(void) { exitcode = 10; } if (fatalexit != 0) { - exitcode = fatalexit; - } - if (dighost_pre_exit_hook != NULL) { - dighost_pre_exit_hook(); + _exit(fatalexit); } exit(exitcode); } @@ -412,6 +407,11 @@ fatal(const char *format, ...) { va_end(args); fprintf(stderr, "\n"); isc__tls_setfatalmode(); + if (fatalexit == 0 && exitcode != 0) { + fatalexit = exitcode; + } else if (fatalexit == 0) { + fatalexit = EXIT_FAILURE; + } digexit(); } diff --git a/bin/dnssec/dnssectool.c b/bin/dnssec/dnssectool.c index 59fc80b3f6..60c6e31832 100644 --- a/bin/dnssec/dnssectool.c +++ b/bin/dnssec/dnssectool.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -84,7 +85,9 @@ fatal(const char *format, ...) { (*fatalcallback)(); } isc__tls_setfatalmode(); - exit(1); + + /* Make sure that various atexit() calls are skipped */ + _exit(EXIT_FAILURE); } void diff --git a/bin/named/main.c b/bin/named/main.c index 36c0a55361..00ef0e0f7f 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -194,7 +194,7 @@ named_main_earlyfatal(const char *format, ...) { } va_end(args); - exit(1); + _exit(EXIT_FAILURE); } noreturn static void @@ -233,7 +233,7 @@ assertion_failed(const char *file, int line, isc_assertiontype_t type, if (named_g_coreok) { abort(); } - exit(1); + _exit(EXIT_FAILURE); } noreturn static void @@ -273,7 +273,7 @@ library_fatal_error(const char *file, int line, const char *func, if (named_g_coreok) { abort(); } - exit(1); + _exit(EXIT_FAILURE); } static void diff --git a/bin/named/server.c b/bin/named/server.c index 6f9463f344..0992923744 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -10204,7 +10204,7 @@ fatal(const char *msg, isc_result_t result) { "exiting (due to fatal error)"); named_os_shutdown(); isc__tls_setfatalmode(); - exit(1); + _exit(EXIT_FAILURE); } static isc_result_t diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 7290ab28aa..39858f30d0 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -280,7 +280,7 @@ fatal(const char *format, ...) { va_end(args); fprintf(stderr, "\n"); isc__tls_setfatalmode(); - exit(1); + _exit(EXIT_FAILURE); } static void diff --git a/bin/rndc/util.c b/bin/rndc/util.c index 23b7f3fd57..948ca87334 100644 --- a/bin/rndc/util.c +++ b/bin/rndc/util.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -46,5 +47,5 @@ fatal(const char *format, ...) { va_end(args); fprintf(stderr, "\n"); isc__tls_setfatalmode(); - exit(1); + _exit(EXIT_FAILURE); } diff --git a/bin/tools/dnstap-read.c b/bin/tools/dnstap-read.c index b998d9db7f..d66f829f2b 100644 --- a/bin/tools/dnstap-read.c +++ b/bin/tools/dnstap-read.c @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -83,7 +84,7 @@ fatal(const char *format, ...) { vfprintf(stderr, format, args); va_end(args); fprintf(stderr, "\n"); - exit(1); + _exit(EXIT_FAILURE); } static void diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index 1c36679403..8fb98e9f74 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -898,7 +898,7 @@ fatal(const char *format, ...) { va_end(args); fprintf(stderr, "\n"); isc__tls_setfatalmode(); - exit(-2); + _exit(EXIT_FAILURE); } static isc_result_t diff --git a/bin/tools/named-rrchecker.c b/bin/tools/named-rrchecker.c index b20a7e7d28..19e59f1e4c 100644 --- a/bin/tools/named-rrchecker.c +++ b/bin/tools/named-rrchecker.c @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -75,7 +76,7 @@ fatal(const char *format, ...) { va_end(args); fputc('\n', stderr); cleanup(); - exit(1); + _exit(EXIT_FAILURE); } int diff --git a/bin/tools/nsec3hash.c b/bin/tools/nsec3hash.c index aaa52d0bb0..b114c0280e 100644 --- a/bin/tools/nsec3hash.c +++ b/bin/tools/nsec3hash.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -48,7 +49,7 @@ fatal(const char *format, ...) { va_end(args); fprintf(stderr, "\n"); isc__tls_setfatalmode(); - exit(1); + _exit(1); } static void