Signed-off-by: Federico Simoncelli fsimonce@redhat.com --- wdmd/main.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/wdmd/main.c b/wdmd/main.c index 28fa042..1f1395a 100644 --- a/wdmd/main.c +++ b/wdmd/main.c @@ -1030,7 +1030,8 @@ static void process_signals(int ci) return; }
- if (fdsi.ssi_signo == SIGTERM) { + if ((fdsi.ssi_signo == SIGTERM) || + (fdsi.ssi_signo == SIGINT)) { if (!active_clients()) daemon_quit = 1; } @@ -1047,6 +1048,7 @@ static int setup_signals(void)
sigemptyset(&mask); sigaddset(&mask, SIGTERM); + sigaddset(&mask, SIGINT); sigaddset(&mask, SIGHUP);
rv = sigprocmask(SIG_BLOCK, &mask, NULL);
Signed-off-by: Federico Simoncelli fsimonce@redhat.com --- src/sysconfig.sanlock => init.d/sanlock.sysconfig | 0 init.d/wdmd.sysconfig | 6 ++++ wdmd/main.c | 29 ++++++++++++-------- 3 files changed, 23 insertions(+), 12 deletions(-) rename src/sysconfig.sanlock => init.d/sanlock.sysconfig (100%) create mode 100644 init.d/wdmd.sysconfig
diff --git a/src/sysconfig.sanlock b/init.d/sanlock.sysconfig similarity index 100% rename from src/sysconfig.sanlock rename to init.d/sanlock.sysconfig diff --git a/init.d/wdmd.sysconfig b/init.d/wdmd.sysconfig new file mode 100644 index 0000000..bb79876 --- /dev/null +++ b/init.d/wdmd.sysconfig @@ -0,0 +1,6 @@ +# WDMDOPTS -- set the command line options for the sanlock daemon +# See wdmd man page for full list of command line options. +# +# To select a specific watchdog device +#WDMDOPTS="-G sanlock -w /dev/watchdog1" + diff --git a/wdmd/main.c b/wdmd/main.c index 1f1395a..9ea0018 100644 --- a/wdmd/main.c +++ b/wdmd/main.c @@ -65,6 +65,7 @@ static int shm_fd; static int allow_scripts; static int kill_script_sec; static char *scripts_dir = (char *)"/etc/wdmd.d"; +static char *watchdog_path = "/dev/watchdog";
struct script_status { uint64_t start; @@ -922,13 +923,13 @@ static int open_dev(void) int fd;
if (dev_fd != -1) { - log_error("/dev/watchdog already open fd %d", dev_fd); + log_error("watchdog already open fd %d", dev_fd); return -1; }
- fd = open("/dev/watchdog", O_WRONLY | O_CLOEXEC); + fd = open(watchdog_path, O_WRONLY | O_CLOEXEC); if (fd < 0) { - log_error("no /dev/watchdog, load a watchdog driver"); + log_error("no %s, load a watchdog driver", watchdog_path); return fd; }
@@ -943,7 +944,7 @@ static void close_watchdog_unclean(void) return; }
- log_error("/dev/watchdog closed unclean"); + log_error("%s closed unclean", watchdog_path); close(dev_fd); dev_fd = -1;
@@ -961,9 +962,9 @@ static void close_watchdog(void)
rv = write(dev_fd, "V", 1); if (rv < 0) - log_error("/dev/watchdog disarm write error %d", errno); + log_error("%s disarm write error %d", watchdog_path, errno); else - log_error("/dev/watchdog disarmed"); + log_error("%s disarmed", watchdog_path);
close(dev_fd); dev_fd = -1; @@ -981,7 +982,7 @@ static int setup_watchdog(void)
rv = ioctl(dev_fd, WDIOC_GETTIMEOUT, &timeout); if (rv < 0) { - log_error("/dev/watchdog failed to report timeout"); + log_error("%s failed to report timeout", watchdog_path); close_watchdog(); return -1; } @@ -993,18 +994,18 @@ static int setup_watchdog(void)
rv = ioctl(dev_fd, WDIOC_SETTIMEOUT, &timeout); if (rv < 0) { - log_error("/dev/watchdog failed to set timeout"); + log_error("%s failed to set timeout", watchdog_path); close_watchdog(); return -1; }
if (timeout != fire_timeout) { - log_error("/dev/watchdog failed to set new timeout"); + log_error("%s failed to set new timeout", watchdog_path); close_watchdog(); return -1; } out: - log_error("/dev/watchdog armed with fire_timeout %d", fire_timeout); + log_error("%s armed with fire_timeout %d", watchdog_path, fire_timeout);
return 0; } @@ -1153,7 +1154,7 @@ static int test_loop(void) if (dev_fd == -1) { open_dev(); pet_watchdog(); - log_error("/dev/watchdog reopen"); + log_error("%s reopen", watchdog_path); } else { pet_watchdog(); } @@ -1330,6 +1331,7 @@ static void print_usage_and_exit(int status) printf("-s <path> path to scripts dir (default %s)\n", scripts_dir); printf("-k <num> kill unfinished scripts after num seconds (default %d)\n", kill_script_sec); + printf("-w /dev/watchdog path to the watchdog device (default %s)\n", watchdog_path); exit(status); }
@@ -1362,7 +1364,7 @@ int main(int argc, char *argv[]) {0, 0, 0, 0 } };
- c = getopt_long(argc, argv, "hdVDFH:G:S:s:k:", + c = getopt_long(argc, argv, "hdVDFH:G:S:s:k:w:", long_options, &option_index); if (c == -1) break; @@ -1398,6 +1400,9 @@ int main(int argc, char *argv[]) case 'k': kill_script_sec = atoi(optarg); break; + case 'w': + watchdog_path = strdup(optarg); + break; } }
sanlock-devel@lists.fedorahosted.org