~cyphermox/ubuntu/natty/connman/release-0.64

« back to all changes in this revision

Viewing changes to src/log.c

  • Committer: Mathieu Trudel-Lapierre
  • Date: 2010-11-30 15:51:10 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: mathieu.trudel-lapierre@canonical.com-20101130155110-32g0usyc4jbl131x
New upstream release 0.64.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <config.h>
24
24
#endif
25
25
 
 
26
#define _GNU_SOURCE
26
27
#include <stdarg.h>
27
28
#include <syslog.h>
 
29
#include <stdlib.h>
 
30
#include <execinfo.h>
 
31
#include <dlfcn.h>
28
32
 
29
33
#include "connman.h"
30
34
 
100
104
        va_end(ap);
101
105
}
102
106
 
 
107
static void signal_handler(int signo)
 
108
{
 
109
        void *frames[64];
 
110
        char **symbols;
 
111
        size_t n_ptrs;
 
112
        unsigned int i;
 
113
 
 
114
        n_ptrs = backtrace(frames, G_N_ELEMENTS(frames));
 
115
        symbols = backtrace_symbols(frames, n_ptrs);
 
116
        if (symbols == NULL) {
 
117
                connman_error("No backtrace symbols");
 
118
                exit(1);
 
119
        }
 
120
 
 
121
        connman_error("Aborting (signal %d)", signo);
 
122
        connman_error("++++++++ backtrace ++++++++");
 
123
 
 
124
        for (i = 1; i < n_ptrs; i++)
 
125
                connman_error("[%d]: %s", i - 1, symbols[i]);
 
126
 
 
127
        connman_error("+++++++++++++++++++++++++++");
 
128
 
 
129
        g_free(symbols);
 
130
        exit(1);
 
131
}
 
132
 
 
133
static void signal_setup(sighandler_t handler)
 
134
{
 
135
        struct sigaction sa;
 
136
        sigset_t mask;
 
137
 
 
138
        sigemptyset(&mask);
 
139
        sa.sa_handler = handler;
 
140
        sa.sa_mask = mask;
 
141
        sa.sa_flags = 0;
 
142
        sigaction(SIGBUS, &sa, NULL);
 
143
        sigaction(SIGILL, &sa, NULL);
 
144
        sigaction(SIGFPE, &sa, NULL);
 
145
        sigaction(SIGSEGV, &sa, NULL);
 
146
        sigaction(SIGABRT, &sa, NULL);
 
147
        sigaction(SIGPIPE, &sa, NULL);
 
148
}
 
149
 
103
150
extern struct connman_debug_desc __start___debug[];
104
151
extern struct connman_debug_desc __stop___debug[];
105
152
 
179
226
        if (detach == FALSE)
180
227
                option |= LOG_PERROR;
181
228
 
 
229
        signal_setup(signal_handler);
 
230
 
182
231
        openlog("connmand", option, LOG_DAEMON);
183
232
 
184
233
        syslog(LOG_INFO, "Connection Manager version %s", VERSION);
192
241
 
193
242
        closelog();
194
243
 
 
244
        signal_setup(SIG_DFL);
 
245
 
195
246
        g_strfreev(enabled);
196
247
}