From b12b94ce34c063612d2fe424e502eb1c96a6670b Mon Sep 17 00:00:00 2001 From: Lon Hohberger <lhh@redhat.com> Date: Mon, 28 Jun 2010 16:28:06 -0400 Subject: [PATCH] rgmanager: Use sysrq-b to reboot This resolves an issue where the reboot() syscall does not complete in rebooting the system, delaying recovery if the main rgmanager process dies. Resolves: rhbz#608397 Signed-off-by: Lon Hohberger <lhh@redhat.com> --- rgmanager/src/daemons/watchdog.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/rgmanager/src/daemons/watchdog.c b/rgmanager/src/daemons/watchdog.c index 9e3e9ac..abd2de1 100644 --- a/rgmanager/src/daemons/watchdog.c +++ b/rgmanager/src/daemons/watchdog.c @@ -22,6 +22,7 @@ #include <sys/reboot.h> #include <stdlib.h> #include <sys/mman.h> +#include <fcntl.h> #include <signals.h> #include <clulog.h> @@ -52,6 +53,23 @@ redirect_signals(void) } } +int +sysrq_reboot(void) +{ + int fd; + + fd = open("/proc/sysrq-trigger", O_WRONLY|O_SYNC); + if (fd < 0) + return fd; + + write(fd, "b\n", 2); + fsync(fd); + fdatasync(fd); + close(fd); + + return 0; +} + /** return watchdog's pid, or 0 on failure */ @@ -93,6 +111,7 @@ watchdog_init(void) #else clulog(LOG_CRIT, "Watchdog: Daemon died, rebooting...\n"); sync(); + sysrq_reboot(); reboot(RB_AUTOBOOT); #endif exit(255); -- 1.6.2.5