X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshutdown.c;h=9f65b1dab0b78aeed203717b75ba3852cc3ceb1e;hb=2d13da8821b8197e62f819b5b996750800e910ab;hp=d157e0fbfeaf4db91cea33666f9e2ab5c59c3633;hpb=19c5f19d69bb5f520fa7213239490c55de06d99d;p=elogind.git diff --git a/src/shutdown.c b/src/shutdown.c index d157e0fbf..9f65b1dab 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -42,6 +42,7 @@ #include "umount.h" #include "util.h" #include "virt.h" +#include "watchdog.h" #define TIMEOUT_USEC (5 * USEC_PER_SEC) #define FINALIZE_ATTEMPTS 50 @@ -306,7 +307,7 @@ int main(int argc, char *argv[]) { int cmd, r; unsigned retries; bool need_umount = true, need_swapoff = true, need_loop_detach = true, need_dm_detach = true; - bool killed_everbody = false, in_container; + bool killed_everbody = false, in_container, use_watchdog = false; log_parse_environment(); log_set_target(LOG_TARGET_CONSOLE); /* syslog will die if not gone yet */ @@ -342,6 +343,8 @@ int main(int argc, char *argv[]) { goto error; } + use_watchdog = !!getenv("WATCHDOG_USEC"); + /* lock us into memory */ if (mlockall(MCL_CURRENT|MCL_FUTURE) != 0) log_warning("Cannot lock process memory: %m"); @@ -359,6 +362,9 @@ int main(int argc, char *argv[]) { for (retries = 0; retries < FINALIZE_ATTEMPTS; retries++) { bool changed = false; + if (use_watchdog) + watchdog_ping(); + if (need_umount) { log_info("Unmounting file systems."); r = umount_all(&changed);