]> arthur.barton.de Git - netdata.git/commitdiff
when debug is enabled, core dump
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 29 Mar 2016 22:19:24 +0000 (01:19 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 29 Mar 2016 22:19:24 +0000 (01:19 +0300)
src/main.c

index a2645bd26333bfd5565245e8dd5361a67540effa..aaddc9d06f74e183c681675534d65eae636d2abc 100755 (executable)
@@ -14,6 +14,7 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/mman.h>
+#include <sys/prctl.h>
 
 #include "common.h"
 #include "log.h"
@@ -276,6 +277,7 @@ int main(int argc, char **argv)
                        struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
                        if(setrlimit(RLIMIT_CORE, &rl) != 0)
                                info("Cannot request unlimited core dumps for debugging... Proceeding anyway...");
+                       prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
                }
 
                // --------------------------------------------------------------------
@@ -420,6 +422,14 @@ int main(int argc, char **argv)
                exit(1);
        }
 
+       if(debug_flags != 0) {
+               struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
+               if(setrlimit(RLIMIT_CORE, &rl) != 0)
+                       info("Cannot request unlimited core dumps for debugging... Proceeding anyway...");
+
+               prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
+       }
+
        if(output_log_syslog || error_log_syslog || access_log_syslog)
                openlog("netdata", LOG_PID, LOG_DAEMON);