aboutsummaryrefslogtreecommitdiff
path: root/src/lib/err/torerr_sys.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-11-01 12:40:55 -0400
committerNick Mathewson <nickm@torproject.org>2018-11-05 09:22:02 -0500
commit175153a3290b3987faacac9d5390e87e1ad4a457 (patch)
treeffe76b1752c481a4e0b47aeb2c21adb58d38a179 /src/lib/err/torerr_sys.c
parent6e7ff8cba0efaf803e3ef5b5aba4123633fe0658 (diff)
downloadtor-175153a3290b3987faacac9d5390e87e1ad4a457.tar.gz
tor-175153a3290b3987faacac9d5390e87e1ad4a457.zip
Make initialization for the "err" library into a subsystem.
Diffstat (limited to 'src/lib/err/torerr_sys.c')
-rw-r--r--src/lib/err/torerr_sys.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/lib/err/torerr_sys.c b/src/lib/err/torerr_sys.c
new file mode 100644
index 0000000000..54666f4106
--- /dev/null
+++ b/src/lib/err/torerr_sys.c
@@ -0,0 +1,39 @@
+/* Copyright (c) 2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file torerr_sys.c
+ * \brief Subsystem object for the error handling subsystem.
+ **/
+
+#include "orconfig.h"
+#include "lib/err/backtrace.h"
+#include "lib/err/torerr.h"
+#include "lib/err/torerr_sys.h"
+#include "lib/subsys/subsys.h"
+#include "lib/version/torversion.h"
+
+#include <stddef.h>
+
+static int
+torerr_subsys_init(void)
+{
+ configure_backtrace_handler(get_version());
+ tor_log_reset_sigsafe_err_fds();
+
+ return 0;
+}
+static void
+torerr_subsys_shutdown(void)
+{
+ tor_log_reset_sigsafe_err_fds();
+ clean_up_backtrace_handler();
+}
+
+const subsys_fns_t sys_torerr = {
+ .name = "err",
+ .level = -100,
+ .supported = true,
+ .initialize = torerr_subsys_init,
+ .shutdown = torerr_subsys_shutdown
+};