[Nagios-devel] Nagios coredumps

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Nagios coredumps

Post by Guest »

This is a multi-part message in MIME format.
--------------040802090606050600060607
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

The daemon_dumps_core config option is really nifty (although redundant
since all systems with RLIMIT_* definitions have ulimit as well), but
unfortunately it's slightly broken. SIGSEGV is still handled by
sighandler, the daemon still does chdir("/") and non-daemon mode doesn't
dump core by default.

The attached patch takes care of it (and also sets it to TRUE by
default, a beta release should dump core if you ask me), and forces
coredumps if any of the DEBUG macros are defined, which is most likely
preferrable.

Cheers

--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Lead Developer

--------------040802090606050600060607
Content-Type: text/plain;
name="nagios-coredump-fixes.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="nagios-coredump-fixes.diff"

diff -urN ../nagios.orig/base/nagios.c ./base/nagios.c
--- ../nagios.orig/base/nagios.c Wed Jan 19 12:27:24 2005
+++ ./base/nagios.c Wed Jan 19 14:24:34 2005
@@ -149,7 +149,7 @@
int test_scheduling=FALSE;

int daemon_mode=FALSE;
-int daemon_dumps_core=FALSE;
+int daemon_dumps_core=TRUE;

int ipc_pipe[2];

diff -urN ../nagios.orig/base/utils.c ./base/utils.c
--- ../nagios.orig/base/utils.c Wed Jan 19 12:27:24 2005
+++ ./base/utils.c Wed Jan 19 14:56:22 2005
@@ -3235,7 +3235,10 @@
signal(SIGQUIT,sighandler);
signal(SIGTERM,sighandler);
signal(SIGHUP,sighandler);
- signal(SIGSEGV,sighandler);
+#if !defined(DEBUG0) && !defined(DEBUG1) && !defined(DEBUG2) && !defined(DEBUG3) && !defined(DEBUG4) && !defined(DEBUG5)
+ if(daemon_dumps_core==FALSE || daemon_mode==FALSE)
+ signal(SIGSEGV,sighandler);
+#endif

#ifdef DEBUG0
printf("setup_sighandler() end\n");
@@ -3380,7 +3383,11 @@
struct rlimit limit;
#endif

- chdir("/"); /* change working directory */
+ /* change working directory. scuttle home if we're dumping core */
+ if(daemon_dumps_core==TRUE)
+ chdir(getenv("HOME"));
+ else
+ chdir("/");

umask(S_IWGRP|S_IWOTH);


--------------040802090606050600060607--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked