+const char *get_signal_name(int sig)
+{
+ if (sig < 0 || sig > BA_NSIG || !sig_names[sig]) {
+ return _("Invalid signal number");
+ } else {
+ return sig_names[sig];
+ }
+}
+
+/* defined in jcr.c */
+extern void dbg_print_jcr(FILE *fp);
+/* defined in plugins.c */
+extern void dbg_print_plugin(FILE *fp);
+/* defined in lockmgr.c */
+extern void dbg_print_lock(FILE *fp);
+
+/*
+ * !!! WARNING !!!
+ *
+ * This function should be used ONLY after a violent signal. We walk through the
+ * JCR chain without locking, Bacula should not be running.
+ */
+static void dbg_print_bacula()
+{
+ char buf[512];
+
+ snprintf(buf, sizeof(buf), "%s/%s.%d.bactrace",
+ working_directory, my_name, (int)getpid());
+ FILE *fp = fopen(buf, "a+") ;
+ if (!fp) {
+ fp = stderr;
+ }
+
+ fprintf(stderr, "Dumping: %s\n", buf);
+
+ /* Print also B_DB and RWLOCK structure
+ * Can add more info about JCR with dbg_jcr_add_hook()
+ */
+ dbg_print_lock(fp);
+ dbg_print_jcr(fp);
+ dbg_print_plugin(fp);
+
+ if (fp != stderr) {
+#define direct_print
+#ifdef direct_print
+ if (prt_kaboom) {
+ rewind(fp);
+ printf("\n\n ==== bactrace output ====\n\n");
+ while (fgets(buf, (int)sizeof(buf), fp) != NULL) {
+ printf("%s", buf);
+ }
+ printf(" ==== End baktrace output ====\n\n");
+ }
+#else
+ if (prt_kaboom) {
+ char buf1[512];
+ printf("\n\n ==== bactrace output ====\n\n");
+ snprintf(buf1, sizeof(buf1), "/bin/cat %s", buf);
+ system(buf1);
+ printf(" ==== End baktrace output ====\n\n");
+ }
+#endif
+ fclose(fp);
+ }
+}
+
+/*