torerr_sys.c 1012 B

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