log: Disable stack trace from command line
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 26 Sep 2012 13:01:36 +0000 (16:01 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 28 Sep 2012 06:39:41 +0000 (09:39 +0300)
Add a '--nobacktrace' command line switch to let the system
handle stack traces. The default is to let ConnMan handle them
as before

src/connman.h
src/log.c
src/main.c
unit/test-nat.c

index c70f6ae..2f6746e 100644 (file)
@@ -114,8 +114,8 @@ int __connman_agent_report_error(struct connman_service *service,
 #include <connman/log.h>
 
 int __connman_log_init(const char *program, const char *debug,
-                                               connman_bool_t detach);
-void __connman_log_cleanup(void);
+               connman_bool_t detach, connman_bool_t backtrace);
+void __connman_log_cleanup(connman_bool_t backtrace);
 void __connman_log_enable(struct connman_debug_desc *start,
                                        struct connman_debug_desc *stop);
 
index 7d1896c..9a68a4b 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -292,7 +292,7 @@ void __connman_log_enable(struct connman_debug_desc *start,
 }
 
 int __connman_log_init(const char *program, const char *debug,
-                                               connman_bool_t detach)
+               connman_bool_t detach, connman_bool_t backtrace)
 {
        static char path[PATH_MAX];
        int option = LOG_NDELAY | LOG_PID;
@@ -308,7 +308,8 @@ int __connman_log_init(const char *program, const char *debug,
        if (detach == FALSE)
                option |= LOG_PERROR;
 
-       signal_setup(signal_handler);
+       if (backtrace == TRUE)
+               signal_setup(signal_handler);
 
        openlog(basename(program), option, LOG_DAEMON);
 
@@ -317,13 +318,14 @@ int __connman_log_init(const char *program, const char *debug,
        return 0;
 }
 
-void __connman_log_cleanup(void)
+void __connman_log_cleanup(connman_bool_t backtrace)
 {
        syslog(LOG_INFO, "Exit");
 
        closelog();
 
-       signal_setup(SIG_DFL);
+       if (backtrace == TRUE)
+               signal_setup(SIG_DFL);
 
        g_strfreev(enabled);
 }
index 62e5c54..d14cee6 100644 (file)
@@ -355,6 +355,7 @@ static gchar *option_noplugin = NULL;
 static gchar *option_wifi = NULL;
 static gboolean option_detach = TRUE;
 static gboolean option_dnsproxy = TRUE;
+static gboolean option_backtrace = TRUE;
 static gboolean option_version = FALSE;
 
 static gboolean parse_debug(const char *key, const char *value,
@@ -391,6 +392,9 @@ static GOptionEntry options[] = {
        { "nodnsproxy", 'r', G_OPTION_FLAG_REVERSE,
                                G_OPTION_ARG_NONE, &option_dnsproxy,
                                "Don't enable DNS Proxy" },
+       { "nobacktrace", 0, G_OPTION_FLAG_REVERSE,
+                               G_OPTION_ARG_NONE, &option_backtrace,
+                               "Don't print out backtrace information" },
        { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
                                "Show version information and exit" },
        { NULL },
@@ -530,7 +534,8 @@ int main(int argc, char *argv[])
 
        g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL);
 
-       __connman_log_init(argv[0], option_debug, option_detach);
+       __connman_log_init(argv[0], option_debug, option_detach,
+                       option_backtrace);
 
        __connman_dbus_init(conn);
 
@@ -622,7 +627,7 @@ int main(int argc, char *argv[])
 
        __connman_dbus_cleanup();
 
-       __connman_log_cleanup();
+       __connman_log_cleanup(option_backtrace);
 
        dbus_connection_unref(conn);
 
index 578ff3e..4a48461 100644 (file)
@@ -147,7 +147,7 @@ int main(int argc, char *argv[])
 
        g_test_init(&argc, &argv, NULL);
 
-       __connman_log_init(argv[0], "*", FALSE);
+       __connman_log_init(argv[0], "*", FALSE, TRUE);
        __connman_iptables_init();
        __connman_nat_init();
 
@@ -159,7 +159,7 @@ int main(int argc, char *argv[])
 
        __connman_nat_cleanup();
        __connman_iptables_cleanup();
-       __connman_log_cleanup();
+       __connman_log_cleanup(TRUE);
 
        return err;
 }