Line data Source code
1 : /* Copyright (c) 2018-2021, The Tor Project, Inc. */ 2 : /* See LICENSE for licensing information */ 3 : 4 : /** 5 : * \file torerr_sys.c 6 : * \brief Subsystem object for the error handling subsystem. 7 : **/ 8 : 9 : #include "orconfig.h" 10 : #include "lib/err/backtrace.h" 11 : #include "lib/err/torerr.h" 12 : #include "lib/err/torerr_sys.h" 13 : #include "lib/subsys/subsys.h" 14 : #include "lib/version/torversion.h" 15 : 16 : #include <stddef.h> 17 : 18 : static int 19 5553 : subsys_torerr_initialize(void) 20 : { 21 5553 : if (configure_backtrace_handler(get_version()) < 0) 22 : return -1; 23 5553 : tor_log_reset_sigsafe_err_fds(); 24 : 25 5553 : return 0; 26 : } 27 : static void 28 235 : subsys_torerr_shutdown(void) 29 : { 30 : /* Stop handling signals with backtraces, then flush the logs. */ 31 235 : clean_up_backtrace_handler(); 32 235 : tor_log_flush_sigsafe_err_fds(); 33 235 : } 34 : 35 : const subsys_fns_t sys_torerr = { 36 : .name = "err", 37 : SUBSYS_DECLARE_LOCATION(), 38 : /* Low-level error handling is a diagnostic feature, we want it to init 39 : * right after windows process security, and shutdown last. 40 : * (Security never shuts down.) */ 41 : .level = -99, 42 : .supported = true, 43 : .initialize = subsys_torerr_initialize, 44 : .shutdown = subsys_torerr_shutdown 45 : };