@cryptotaxi247 / netdata-1 / commits / 0fffe00ce

when debug is enabled, core dump

Costa Tsaousis (ktsaou) committed Mar 30, 2016 at 01:19 UTC 0fffe00ce88d4af2dd1a4c781250d635211b4663
1 file changed +10
src/main.c
+10
@@ -14,6 +14,7 @@
14 #include <sys/time.h>
15 #include <sys/resource.h>
16 #include <sys/mman.h>
17 +#include <sys/prctl.h>
18
19 #include "common.h"
20 #include "log.h"
@@ -276,6 +277,7 @@ int main(int argc, char **argv)
277 struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
278 if(setrlimit(RLIMIT_CORE, &rl) != 0)
279 info("Cannot request unlimited core dumps for debugging... Proceeding anyway...");
280 + prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
281 }
282
283 // --------------------------------------------------------------------
@@ -420,6 +422,14 @@ int main(int argc, char **argv)
422 exit(1);
423 }
424
425 + if(debug_flags != 0) {
426 + struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
427 + if(setrlimit(RLIMIT_CORE, &rl) != 0)
428 + info("Cannot request unlimited core dumps for debugging... Proceeding anyway...");
429 +
430 + prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
431 + }
432 +
433 if(output_log_syslog || error_log_syslog || access_log_syslog)
434 openlog("netdata", LOG_PID, LOG_DAEMON);
435