extern char my_name[];
extern char *exepath;
extern char *exename;
+extern void print_jcr_dbg();
static const char *sig_names[BA_NSIG+1];
}
}
+/* defined in jcr.c */
+extern void _dbg_print_jcr(FILE *fp);
+/* defined in plugin.c */
+extern void _dbg_print_plugin(FILE *fp);
+
+/*
+ * !!! WARNING !!!
+ *
+ * This function should be used ONLY after a violent signal. We walk through the
+ * JCR chain without doing any lock, bacula should not be running.
+ */
+static void dbg_print_bacula()
+{
+ char buf[512];
+
+ snprintf(buf, sizeof(buf), "%s/bacula.%d.bactrace",
+ working_directory, getpid());
+ FILE *fp = fopen(buf, "ab") ;
+ if (!fp) {
+ fp = stderr;
+ }
+
+ /* Print also B_DB and RWLOCK structure
+ * Can add more info about JCR with dbg_jcr_add_hook()
+ */
+ _dbg_print_jcr(fp);
+
+ _dbg_print_plugin(fp);
+
+ if (fp != stderr) {
+ fclose(fp);
+ }
+}
+
/*
* Handle signals here
*/
default: /* parent */
break;
}
+
/* Parent continue here, waiting for child */
sigdefault.sa_flags = 0;
sigdefault.sa_handler = SIG_DFL;
if (pid > 0) {
Dmsg0(500, "Doing waitpid\n");
waitpid(pid, NULL, 0); /* wait for child to produce dump */
- fprintf(stderr, _("Traceback complete, attempting cleanup ...\n"));
Dmsg0(500, "Done waitpid\n");
+ fprintf(stderr, _("Traceback complete, attempting cleanup ...\n"));
+ /* print information about the current state into working/<file>.bactrace */
+ dbg_print_bacula();
exit_handler(sig); /* clean up if possible */
Dmsg0(500, "Done exit_handler\n");
} else {