13 #include <sys/ioctl.h> 14 #include <sys/reboot.h> 16 #include <sys/types.h> 23 static pid_t sbd_pid = 0;
36 FILE *procf = fopen(
"/proc/sysrq-trigger",
"a");
39 crm_warn(
"Could not open sysrq-trigger: %s", strerror(errno));
41 fprintf(procf,
"%c\n", t);
44 #endif // HAVE_LINUX_PROCFS 54 panic_local_nonroot(pid_t ppid)
63 union sigval signal_value;
67 memset(&signal_value, 0,
sizeof(signal_value));
68 if (sigqueue(ppid, SIGQUIT, signal_value) < 0) {
69 crm_emerg(
"Exiting after signal failure: %s", strerror(errno));
90 const char *panic_action = full_panic_action;
91 int reboot_cmd = RB_AUTOBOOT;
94 panic_local_nonroot(getppid());
99 panic_action +=
sizeof(
"sync-") - 1;
103 if (pcmk__str_empty(full_panic_action)
113 reboot_cmd = RB_POWER_OFF;
114 #elif defined(RB_POWEROFF) 115 reboot_cmd = RB_POWEROFF;
128 crm_emerg(
"Exiting after reboot failed: %s", strerror(errno));
143 union sigval signal_value;
144 pid_t ppid = getppid();
146 memset(&signal_value, 0,
sizeof(signal_value));
148 if(sigqueue(sbd_pid, SIGKILL, signal_value) < 0) {
149 crm_emerg(
"Panicking directly because couldn't signal sbd");
175 crm_emerg(
"Signaling sbd[%lld] to panic the system: %s",
176 (
long long) sbd_pid, reason);
180 crm_emerg(
"Panicking the system directly: %s", reason);
192 char *pidfile = NULL;
193 char *sbd_path = NULL;
207 crm_trace(
"SBD detected at pid %lld (via PID file %s)",
208 (
long long) sbd_pid, pidfile);
210 #if HAVE_LINUX_PROCFS 214 crm_trace(
"SBD detected at pid %lld (via procfs)",
215 (
long long) sbd_pid);
216 #endif // HAVE_LINUX_PROCFS 233 static long sbd_timeout = -2;
235 if (sbd_timeout == -2) {
236 sbd_timeout =
crm_get_msec(getenv(
"SBD_WATCHDOG_TIMEOUT"));
245 static bool checked_sync_resource_startup =
false;
247 if (!checked_sync_resource_startup) {
248 const char *sync_env = getenv(
"SBD_SYNC_RESOURCE_STARTUP");
250 if (sync_env == NULL) {
251 crm_trace(
"Defaulting to %sstart-up synchronization with sbd",
255 crm_warn(
"Defaulting to %sstart-up synchronization with sbd " 256 "because environment value '%s' is invalid",
259 checked_sync_resource_startup =
true;
261 return sync_resource_startup != 0;
269 return (sbd_timeout <= 0)? 0 : (2 * sbd_timeout);
281 if (st_timeout < 0) {
283 crm_debug(
"Using calculated value %ld for " 288 if (st_timeout == 0) {
291 value? value :
"default");
295 " configured (%s) but SBD not active",
296 pcmk__s(value,
"auto"));
303 if (st_timeout < sbd_timeout) {
305 " (%s) too short (must be >%ldms)",
311 " %s and SBD timeout %ldms",
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
bool pcmk__get_sbd_sync_resource_startup(void)
const char * pcmk__env_option(const char *option)
#define crm_warn(fmt, args...)
#define crm_emerg(fmt, args...)
#define crm_debug(fmt, args...)
#define PCMK__ENV_PANIC_ACTION
#define crm_trace(fmt, args...)
long pcmk__get_sbd_watchdog_timeout(void)
#define PCMK_VALUE_REBOOT
bool pcmk__valid_stonith_watchdog_timeout(const char *value)
void pcmk__panic(const char *reason)
long long crm_get_msec(const char *input)
Parse a time+units string and return milliseconds equivalent.
pid_t pcmk__procfs_pid_of(const char *name)
#define PCMK__SBD_SYNC_DEFAULT
pid_t pcmk__locate_sbd(void)
long pcmk__auto_stonith_watchdog_timeout(void)
int pcmk__pidfile_matches(const char *filename, pid_t expected_pid, const char *expected_name, pid_t *pid)
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.
#define PCMK__SERVER_PACEMAKERD
#define crm_info(fmt, args...)
#define PCMK_OPT_STONITH_WATCHDOG_TIMEOUT
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1