12 #include <sys/ioctl.h> 
   13 #include <sys/reboot.h> 
   15 #include <sys/types.h> 
   22 #  include <sys/mman.h> 
   25 static int sbd_pid = 0;
 
   35 #define SYSRQ "/proc/sys/kernel/sysrq" 
   40     static bool need_init = 
true;
 
   50     procf = fopen(
SYSRQ, 
"r");
 
   55     if (fscanf(procf, 
"%d", &c) != 1) {
 
   65     procf = fopen(
SYSRQ, 
"w");
 
   70     fprintf(procf, 
"%d", c);
 
   82     procf = fopen(
"/proc/sysrq-trigger", 
"a");
 
   84         crm_perror(LOG_ERR, 
"Opening sysrq-trigger failed");
 
   88     fprintf(procf, 
"%c\n", t);
 
   95 pcmk_panic_local(
void) 
 
   98     uid_t uid = geteuid();
 
   99     pid_t ppid = getppid();
 
  101     if(uid != 0 && ppid > 1) {
 
  111     } 
else if (uid != 0) {
 
  116         union sigval signal_value;
 
  118         memset(&signal_value, 0, 
sizeof(signal_value));
 
  122         if(ppid > 1 && sigqueue(ppid, SIGQUIT, signal_value) < 0) {
 
  123             crm_perror(LOG_EMERG, 
"Cannot signal pacemakerd(%d) to panic", ppid);
 
  132     if (
safe_str_eq(
"crash", getenv(
"PCMK_panic_action"))) {
 
  155     union sigval signal_value;
 
  156     pid_t ppid = getppid();
 
  160     memset(&signal_value, 0, 
sizeof(signal_value));
 
  162     if(sigqueue(sbd_pid, SIGKILL, signal_value) < 0) {
 
  163         crm_perror(LOG_EMERG, 
"Cannot signal SBD(%d) to terminate", sbd_pid);
 
  179     static struct qb_log_callsite *panic_cs = NULL;
 
  181     if (panic_cs == NULL) {
 
  188     if (panic_cs && panic_cs->targets) {
 
  191                           "Shutting down instead of panicking the node: origin=%s, sbd=%d, parent=%d",
 
  192                           origin, sbd_pid, getppid());
 
  198         do_crm_log_always(LOG_EMERG, 
"Signaling sbd(%d) to panic the system: %s", sbd_pid, origin);
 
  210     char *pidfile = NULL;
 
  211     char *sbd_path = NULL;
 
  226         crm_trace(
"SBD detected at pid=%d (file)", sbd_pid);
 
  231         crm_trace(
"SBD detected at pid=%d (proc)", sbd_pid);
 
  248     const char *env_value = getenv(
"SBD_WATCHDOG_TIMEOUT");
 
  259     if (st_timeout <= 0) {
 
  260         crm_debug(
"Watchdog may be enabled but stonith-watchdog-timeout is disabled (%s)",
 
  261                   value? value : 
"default");
 
  265                           "Shutting down: stonith-watchdog-timeout configured (%s) but SBD not active",
 
  273         if (st_timeout < sbd_timeout) {
 
  275                               "Shutting down: stonith-watchdog-timeout (%s) too short (must be >%ldms)",
 
  280         crm_info(
"Watchdog configured with stonith-watchdog-timeout %s and SBD timeout %ldms",
 
long crm_get_sbd_timeout(void)
 
gboolean check_sbd_timeout(const char *value)
 
long crm_pidfile_inuse(const char *filename, long mypid, const char *daemon)
 
const char * pcmk_strerror(int rc)
 
long long crm_get_msec(const char *input)
 
unsigned int crm_trace_nonlog
 
#define crm_debug(fmt, args...)
 
#define crm_trace(fmt, args...)
 
void pcmk_panic(const char *origin)
 
#define do_crm_log_always(level, fmt, args...)
Log a message using constant severity. 
 
#define DAEMON_RESPAWN_STOP
 
#define crm_perror(level, fmt, args...)
Log a system error message. 
 
pid_t pcmk_locate_sbd(void)
 
#define safe_str_eq(a, b)
 
int crm_procfs_pid_of(const char *name)
 
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
 
#define crm_info(fmt, args...)