#include "system/wait.h"
#include "system/filesys.h"
-static void (*cont_fn)(void *);
-
/* the registered fault handler */
static struct {
const char *name;
void (*fault_handler)(int sig);
} fault_handlers;
+static const char *progname;
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
int result;
if (cmd && *cmd) {
- DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmd));
- result = system(cmd);
+ char pidstr[20];
+ char cmdstring[200];
+ safe_strcpy(cmdstring, cmd, sizeof(cmdstring));
+ snprintf(pidstr, sizeof(pidstr), "%u", getpid());
+ all_string_sub(cmdstring, "%PID%", pidstr, sizeof(cmdstring));
+ if (progname) {
+ all_string_sub(cmdstring, "%PROG%", progname, sizeof(cmdstring));
+ }
+ DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmdstring));
+ result = system(cmdstring);
if (result == -1)
DEBUG(0, ("smb_panic(): fork failed in panic action: %s\n",
smb_panic("internal error");
- if (cont_fn) {
- cont_fn(NULL);
-#ifdef SIGSEGV
- CatchSignal(SIGSEGV,SIGNAL_CAST SIG_DFL);
-#endif
-#ifdef SIGBUS
- CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL);
-#endif
-#ifdef SIGABRT
- CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
-#endif
- return; /* this should cause a core dump */
- }
exit(1);
}
/*******************************************************************
setup our fault handlers
********************************************************************/
-void fault_setup(void (*fn)(void *))
+void fault_setup(const char *pname)
{
- cont_fn = fn;
-
+ if (progname == NULL) {
+ progname = pname;
+ }
#ifdef SIGSEGV
CatchSignal(SIGSEGV,SIGNAL_CAST sig_fault);
#endif
*/
static void setup_signals(void)
{
- fault_setup(NULL);
-
/* we are never interested in SIGPIPE */
BlockSignals(True,SIGPIPE);
poptFreeContext(pc);
- setup_logging(NULL, interactive?DEBUG_STDOUT:DEBUG_FILE);
+ setup_logging(argv[0], interactive?DEBUG_STDOUT:DEBUG_FILE);
setup_signals();
/* we want total control over the permissions on created files,