23 #include <sys/ioctl.h> 24 #include <sys/reboot.h> 26 #include <sys/types.h> 33 # include <sys/mman.h> 36 static int sbd_pid = 0;
46 #define SYSRQ "/proc/sys/kernel/sysrq" 51 static bool need_init =
true;
61 procf = fopen(
SYSRQ,
"r");
66 if (fscanf(procf,
"%d", &c) != 1) {
76 procf = fopen(
SYSRQ,
"w");
81 fprintf(procf,
"%d", c);
93 procf = fopen(
"/proc/sysrq-trigger",
"a");
95 crm_perror(LOG_ERR,
"Opening sysrq-trigger failed");
99 fprintf(procf,
"%c\n", t);
106 pcmk_panic_local(
void)
109 uid_t uid = geteuid();
110 pid_t ppid = getppid();
112 if(uid != 0 && ppid > 1) {
122 }
else if (uid != 0) {
127 union sigval signal_value;
129 memset(&signal_value, 0,
sizeof(signal_value));
133 if(ppid > 1 && sigqueue(ppid, SIGQUIT, signal_value) < 0) {
134 crm_perror(LOG_EMERG,
"Cannot signal pacemakerd(%d) to panic", ppid);
162 union sigval signal_value;
163 pid_t ppid = getppid();
167 memset(&signal_value, 0,
sizeof(signal_value));
169 if(sigqueue(sbd_pid, SIGKILL, signal_value) < 0) {
170 crm_perror(LOG_EMERG,
"Cannot signal SBD(%d) to terminate", sbd_pid);
186 static struct qb_log_callsite *panic_cs = NULL;
188 if (panic_cs == NULL) {
194 if (panic_cs && panic_cs->targets) {
197 "Shutting down instead of panicing the node: origin=%s, sbd=%d, parent=%d",
198 origin, sbd_pid, getppid());
204 do_crm_log_always(LOG_EMERG,
"Signaling sbd(%d) to panic the system: %s", sbd_pid, origin);
216 char *pidfile = NULL;
217 char *sbd_path = NULL;
230 if(rc <
pcmk_ok && rc != -ENOENT) {
232 crm_trace(
"SBD detected at pid=%d (file)");
239 crm_trace(
"SBD detected at pid=%d (proc)", sbd_pid);
int crm_procfs_pid_of(const char *name)
const char * pcmk_strerror(int rc)
pid_t pcmk_locate_sbd(void)
unsigned int crm_trace_nonlog
int crm_read_pidfile(const char *filename)
int crm_pidfile_inuse(const char *filename, long mypid, const char *daemon)
#define crm_trace(fmt, args...)
#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.
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
void pcmk_panic(const char *origin)
#define crm_info(fmt, args...)