14#include <sys/reboot.h>
23static pid_t sbd_pid = 0;
32panic_local_nonroot(pid_t ppid)
40 union sigval signal_value;
44 memset(&signal_value, 0,
sizeof(signal_value));
45 if (sigqueue(ppid, SIGQUIT, signal_value) < 0) {
46 crm_emerg(
"Exiting after signal failure: %s", strerror(errno));
64 const char *panic_action = full_panic_action;
65 int reboot_cmd = RB_AUTOBOOT;
68 panic_local_nonroot(getppid());
73 panic_action +=
sizeof(
"sync-") - 1;
77 if (pcmk__str_empty(full_panic_action)
87 reboot_cmd = RB_POWER_OFF;
88#elif defined(RB_POWEROFF)
89 reboot_cmd = RB_POWEROFF;
102 crm_emerg(
"Exiting after reboot failed: %s", strerror(errno));
117 union sigval signal_value;
118 pid_t ppid = getppid();
120 memset(&signal_value, 0,
sizeof(signal_value));
122 if(sigqueue(sbd_pid, SIGKILL, signal_value) < 0) {
123 crm_emerg(
"Panicking directly because couldn't signal sbd");
149 crm_emerg(
"Signaling sbd[%lld] to panic the system: %s",
150 (
long long) sbd_pid, reason);
154 crm_emerg(
"Panicking the system directly: %s", reason);
176 crm_trace(
"SBD detected at pid %lld (via PID file %s)",
177 (
long long) sbd_pid, pidfile);
183 crm_trace(
"SBD detected at pid %lld (via procfs)",
184 (
long long) sbd_pid);
199 static long sbd_timeout = -2;
201 if (sbd_timeout == -2) {
202 sbd_timeout =
crm_get_msec(getenv(
"SBD_WATCHDOG_TIMEOUT"));
211 static bool checked_sync_resource_startup =
false;
213 if (!checked_sync_resource_startup) {
214 const char *sync_env = getenv(
"SBD_SYNC_RESOURCE_STARTUP");
216 if (sync_env == NULL) {
217 crm_trace(
"Defaulting to %sstart-up synchronization with sbd",
221 crm_warn(
"Defaulting to %sstart-up synchronization with sbd "
222 "because environment value '%s' is invalid",
225 checked_sync_resource_startup =
true;
227 return sync_resource_startup != 0;
235 return (sbd_timeout <= 0)? 0 : (2 * sbd_timeout);
247 if (st_timeout < 0) {
249 crm_debug(
"Using calculated value %ld for "
254 if (st_timeout == 0) {
257 value? value :
"default");
261 " configured (%s) but SBD not active",
262 pcmk__s(value,
"auto"));
269 if (st_timeout < sbd_timeout) {
271 " (%s) too short (must be >%ldms)",
277 " %s and SBD timeout %ldms",
void pcmk__sysrq_trigger(char t)
int pcmk__pidfile_matches(const char *filename, pid_t expected_pid, const char *expected_name, pid_t *pid)
pid_t pcmk__procfs_pid_of(const char *name)
#define PCMK__SBD_SYNC_DEFAULT
#define crm_info(fmt, args...)
#define crm_warn(fmt, args...)
#define crm_debug(fmt, args...)
#define crm_trace(fmt, args...)
#define crm_emerg(fmt, args...)
#define PCMK_VALUE_REBOOT
#define PCMK_OPT_STONITH_WATCHDOG_TIMEOUT
#define PCMK__ENV_PANIC_ACTION
const char * pcmk__env_option(const char *option)
@ CRM_EX_PANIC
Panic the local host.
@ CRM_EX_FATAL
Do not respawn.
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
#define PCMK__SERVER_PACEMAKERD
long long crm_get_msec(const char *input)
Parse a time+units string and return milliseconds equivalent.
int crm_str_to_boolean(const char *s, int *ret)
bool pcmk__starts_with(const char *str, const char *prefix)
Check whether a string starts with a certain sequence.
void pcmk__panic(const char *reason)
pid_t pcmk__locate_sbd(void)
long pcmk__get_sbd_watchdog_timeout(void)
bool pcmk__valid_stonith_watchdog_timeout(const char *value)
long pcmk__auto_stonith_watchdog_timeout(void)
bool pcmk__get_sbd_sync_resource_startup(void)