/*
- Unix SMB/Netbios implementation.
- Version 1.9.
+ Unix SMB/CIFS implementation.
Critical Fault handling
Copyright (C) Andrew Tridgell 1992-1998
*/
#include "includes.h"
-extern int DEBUGLEVEL;
-
-
-static void (*cont_fn)();
+static void (*cont_fn)(void *);
/*******************************************************************
report a fault
********************************************************************/
static void fault_report(int sig)
{
- DEBUG(0,("===============================================================\n"));
- DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),VERSION));
- DEBUG(0,("\nPlease read the file BUGS.txt in the distribution\n"));
- DEBUG(0,("===============================================================\n"));
+ static int counter;
+
+ if (counter) _exit(1);
+
+ counter++;
+
+ DEBUG(0,("===============================================================\n"));
+ DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),SAMBA_VERSION_STRING));
+ DEBUG(0,("\nPlease read the appendix Bugs of the Samba HOWTO collection\n"));
+ DEBUG(0,("===============================================================\n"));
-#if AJT
- ajt_panic();
-#endif
+ smb_panic("internal error");
- if (cont_fn)
- {
- fault_setup(cont_fn);
- cont_fn(NULL);
+ if (cont_fn) {
+ cont_fn(NULL);
#ifdef SIGSEGV
- signal(SIGSEGV,SIGNAL_CAST SIG_DFL);
+ CatchSignal(SIGSEGV,SIGNAL_CAST SIG_DFL);
#endif
#ifdef SIGBUS
- signal(SIGBUS,SIGNAL_CAST SIG_DFL);
+ CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL);
#endif
- return; /* this should cause a core dump */
- }
- exit(1);
+#ifdef SIGABRT
+ CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
+#endif
+ return; /* this should cause a core dump */
+ }
+ exit(1);
}
/****************************************************************************
****************************************************************************/
static void sig_fault(int sig)
{
- fault_report(sig);
+ fault_report(sig);
}
/*******************************************************************
setup our fault handlers
********************************************************************/
-void fault_setup(void (*fn)())
+void fault_setup(void (*fn)(void *))
{
- cont_fn = fn;
+ cont_fn = fn;
#ifdef SIGSEGV
- signal(SIGSEGV,SIGNAL_CAST sig_fault);
+ CatchSignal(SIGSEGV,SIGNAL_CAST sig_fault);
#endif
#ifdef SIGBUS
- signal(SIGBUS,SIGNAL_CAST sig_fault);
+ CatchSignal(SIGBUS,SIGNAL_CAST sig_fault);
+#endif
+#ifdef SIGABRT
+ CatchSignal(SIGABRT,SIGNAL_CAST sig_fault);
#endif
}
-
-
-