@cryptotaxi247 / netdata-1 / commits / 577d10484

default signal handler

Costa Tsaousis (ktsaou) committed May 10, 2014 at 05:20 UTC 577d10484cec2e95b7b67d874d472576f2d0a6e8
1 file changed +28 -4
netdata.c
+28 -4
@@ -217,6 +217,29 @@ void debug_int( const char *file, const char *function, const unsigned long line
217 }
218 }
219
220 +#define info(args...) info_int(__FILE__, __FUNCTION__, __LINE__, ##args)
221 +
222 +void info_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
223 +{
224 + if(file) { ; }
225 + va_list args;
226 +
227 + log_date(stderr);
228 +
229 + va_start( args, fmt );
230 + fprintf(stderr, "INFO (%04lu@%-15.15s): ", line, function);
231 + vfprintf( stderr, fmt, args );
232 + va_end( args );
233 +
234 + fprintf(stderr, "\n");
235 +
236 + if(error_log_syslog) {
237 + va_start( args, fmt );
238 + vsyslog(LOG_ERR, fmt, args );
239 + va_end( args );
240 + }
241 +}
242 +
243 #define error(args...) error_int(__FILE__, __FUNCTION__, __LINE__, ##args)
244
245 void error_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
@@ -3326,7 +3349,7 @@ void log_allocations(void)
3349 struct web_client *w;
3350 for(w = web_clients; w ; w = w->next) clients++;
3351
3329 - error("Allocated memory increased from %d to %d (increased by %d bytes). There are %d web clients connected.", mem, mi.uordblks, mi.uordblks - mem, clients);
3352 + info("Allocated memory increased from %d to %d (increased by %d bytes). There are %d web clients connected.", mem, mi.uordblks, mi.uordblks - mem, clients);
3353 mem = mi.uordblks;
3354 }
3355 }
@@ -6223,7 +6246,7 @@ void sig_handler(int signo)
6246 case SIGHUP:
6247 case SIGFPE:
6248 case SIGSEGV:
6226 - error("Signaled exit (signal %d).", signo);
6249 + error("Signaled exit (signal %d). Errno: %d (%s)", signo, errno, strerror(errno));
6250 kill_childs();
6251 exit(1);
6252 break;
@@ -6266,7 +6289,8 @@ void sig_handler(int signo)
6289 break;
6290
6291 default:
6269 - error("Signal %d received. Ignoring it.", signo);
6292 + error("Signal %d received. Falling back to default action for it.", signo);
6293 + signal(signo, SIG_DFL);
6294 break;
6295 }
6296 }
@@ -6618,7 +6642,7 @@ int main(int argc, char **argv)
6642 if(output_log_syslog || error_log_syslog || access_log_syslog)
6643 openlog("netdata", LOG_PID, LOG_DAEMON);
6644
6621 - error("NetData started on pid %d", getpid());
6645 + info("NetData started on pid %d", getpid());
6646
6647
6648 // catch all signals