13 #include <sys/ioctl.h>    14 #include <sys/reboot.h>    16 #include <sys/types.h>    24 #  include <sys/mman.h>    27 static pid_t sbd_pid = 0;
    36     procf = fopen(
"/proc/sysrq-trigger", 
"a");
    38         crm_perror(LOG_WARNING, 
"Opening sysrq-trigger failed");
    42     fprintf(procf, 
"%c\n", t);
    44 #endif // SUPPORT_PROCFS    57     uid_t uid = geteuid();
    58     pid_t ppid = getppid();
    60     if(uid != 0 && ppid > 1) {
    67         crm_emerg(
"Signaling parent %lld to panic", (
long long) ppid);
    71     } 
else if (uid != 0) {
    77         union sigval signal_value;
    79         memset(&signal_value, 0, 
sizeof(signal_value));
    81         crm_emerg(
"Signaling pacemakerd[%lld] to panic", (
long long) ppid);
    83         if(ppid > 1 && sigqueue(ppid, SIGQUIT, signal_value) < 0) {
    84             crm_perror(LOG_EMERG, 
"Cannot signal pacemakerd[%lld] to panic",
    87 #endif // SUPPORT_PROCFS    96     if (pcmk__str_eq(
"crash", getenv(
"PCMK_panic_action"), 
pcmk__str_casei)) {
    98     } 
else if (pcmk__str_eq(
"sync-crash", getenv(
"PCMK_panic_action"), 
pcmk__str_casei)) {
   102         if (pcmk__str_eq(
"sync-reboot", getenv(
"PCMK_panic_action"), 
pcmk__str_casei)) {
   111     crm_emerg(
"Reboot failed, escalating to parent %lld: %s " CRM_XS " rc=%d",
   130     union sigval signal_value;
   131     pid_t ppid = getppid();
   133     crm_emerg(
"Signaling sbd[%lld] to panic", (
long long) sbd_pid);
   135     memset(&signal_value, 0, 
sizeof(signal_value));
   137     if(sigqueue(sbd_pid, SIGKILL, signal_value) < 0) {
   138         crm_perror(LOG_EMERG, 
"Cannot signal sbd[%lld] to terminate",
   139                    (
long long) sbd_pid);
   164     static struct qb_log_callsite *panic_cs = NULL;
   166     if (panic_cs == NULL) {
   167         panic_cs = qb_log_callsite_get(__func__, __FILE__, 
"panic-delay",
   174     if (panic_cs && panic_cs->targets) {
   176         crm_emerg(
"Shutting down instead of panicking the node "   177                   CRM_XS " origin=%s sbd=%lld parent=%d",
   178                   origin, (
long long) sbd_pid, getppid());
   184         crm_emerg(
"Signaling sbd[%lld] to panic the system: %s",
   185                   (
long long) sbd_pid, origin);
   189         crm_emerg(
"Panicking the system directly: %s", origin);
   201     char *pidfile = NULL;
   202     char *sbd_path = NULL;
   216         crm_trace(
"SBD detected at pid %lld (via PID file %s)",
   217                   (
long long) sbd_pid, pidfile);
   223         crm_trace(
"SBD detected at pid %lld (via procfs)",
   224                   (
long long) sbd_pid);
   225 #endif // SUPPORT_PROCFS   242     static long sbd_timeout = -2;
   244     if (sbd_timeout == -2) {
   245         sbd_timeout = 
crm_get_msec(getenv(
"SBD_WATCHDOG_TIMEOUT"));
   254     static bool checked_sync_resource_startup = 
false;
   256     if (!checked_sync_resource_startup) {
   257         const char *sync_env = getenv(
"SBD_SYNC_RESOURCE_STARTUP");
   259         if (sync_env == NULL) {
   260             crm_trace(
"Defaulting to %sstart-up synchronization with sbd",
   264             crm_warn(
"Defaulting to %sstart-up synchronization with sbd "   265                      "because environment value '%s' is invalid",
   268         checked_sync_resource_startup = 
true;
   270     return sync_resource_startup != 0;
   278     return (sbd_timeout <= 0)? 0 : (2 * sbd_timeout);
   286     if (st_timeout < 0) {
   288         crm_debug(
"Using calculated value %ld for stonith-watchdog-timeout (%s)",
   292     if (st_timeout == 0) {
   293         crm_debug(
"Watchdog may be enabled but stonith-watchdog-timeout is disabled (%s)",
   294                   value? value : 
"default");
   297         crm_emerg(
"Shutting down: stonith-watchdog-timeout configured (%s) "   298                   "but SBD not active", (value? value : 
"auto"));
   305         if (st_timeout < sbd_timeout) {
   306             crm_emerg(
"Shutting down: stonith-watchdog-timeout (%s) too short "   307                       "(must be >%ldms)", value, sbd_timeout);
   311         crm_info(
"Watchdog configured with stonith-watchdog-timeout %s and SBD timeout %ldms",
 
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
 
void pcmk__panic(const char *origin)
 
long pcmk__auto_watchdog_timeout()
 
long long crm_get_msec(const char *input)
Parse a time+units string and return milliseconds equivalent. 
 
bool pcmk__get_sbd_sync_resource_startup(void)
 
bool pcmk__valid_sbd_timeout(const char *value)
 
long pcmk__get_sbd_timeout(void)
 
unsigned int crm_trace_nonlog
 
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code. 
 
#define crm_warn(fmt, args...)
 
#define crm_emerg(fmt, args...)
 
#define crm_debug(fmt, args...)
 
#define crm_trace(fmt, args...)
 
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
 
pid_t pcmk__procfs_pid_of(const char *name)
 
int crm_str_to_boolean(const char *s, int *ret)
 
#define PCMK__SBD_SYNC_DEFAULT
 
#define crm_perror(level, fmt, args...)
Send a system error message to both the log and stderr. 
 
pid_t pcmk__locate_sbd(void)
 
int pcmk__pidfile_matches(const char *filename, pid_t expected_pid, const char *expected_name, pid_t *pid)
 
#define crm_info(fmt, args...)