* Several handy miscellaneous functions.
*/
int fr_set_signal(int sig, sig_t func);
+int fr_unset_signal(int sig);
int fr_link_talloc_ctx_free(TALLOC_CTX *parent, TALLOC_CTX *child);
char const *fr_inet_ntop(int af, void const *src);
char const *ip_ntoa(char *, uint32_t);
if (strlen(p) >= left) goto oob;
strlcpy(out, p, left);
- FR_FAULT_LOG("Calling: %s", cmd);
-
{
bool disable = false;
+ FR_FAULT_LOG("Calling: %s", cmd);
+
/*
* Here we temporarily enable the dumpable flag so if GBD or LLDB
* is called in the panic_action, they can pattach to the running
}
}
- fr_exit_now(1);
+ FR_FAULT_LOG("Panic action exited with %i", code);
+
+ fr_exit_now(code);
}
- FR_FAULT_LOG("Panic action exited with %i", code);
finish:
+ /*
+ * (Re-)Raise the signal, so that if we're running under
+ * a debugger, the debugger can break when it receives
+ * the signal.
+ */
+ fr_unset_signal(sig); /* Make sure we don't get into a loop */
+
raise(sig);
+
+ fr_exit_now(1); /* Function marked as noreturn */
}
/** Callback executed on fatal talloc error
return 0;
}
+/** Uninstall a signal for a specific handler
+ *
+ * man sigaction says these are fine to call from a signal handler.
+ *
+ * @param sig SIGNAL
+ */
+int fr_unset_signal(int sig)
+{
+#ifdef HAVE_SIGACTION
+ struct sigaction act;
+
+ memset(&act, 0, sizeof(act));
+ act.sa_flags = 0;
+ sigemptyset(&act.sa_mask);
+ act.sa_handler = SIG_DFL;
+
+ return sigaction(sig, &act, NULL);
+#else
+ return signal(sig, SIG_DFLT);
+#endif
+}
+
static int _fr_trigger_talloc_ctx_free(fr_talloc_link_t *trigger)
{
if (trigger->armed) talloc_free(trigger->child);
return 0;
}
-
+
/*
* Copy the IP portion into a temporary buffer if we haven't already.
*/