chiark / gitweb /
split selinux label operations out of cgroup-util, socket-util
[elogind.git] / src / shutdown.c
index 46b5aea1c80d940b385db0ccb9264fbfb6881e93..b0c680a030cbc2d2f5fd4d94185fe49b6bbcefd4 100644 (file)
@@ -41,7 +41,9 @@
 #include "log.h"
 #include "umount.h"
 #include "util.h"
+#include "mkdir.h"
 #include "virt.h"
+#include "watchdog.h"
 
 #define TIMEOUT_USEC (5 * USEC_PER_SEC)
 #define FINALIZE_ATTEMPTS 50
@@ -81,7 +83,9 @@ static bool ignore_proc(pid_t pid) {
                 return true;
 
         /* Processes with argv[0][0] = '@' we ignore from the killing
-         * spree. */
+         * spree.
+         *
+         * http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons */
         if (count == 1 && c == '@')
                 return true;
 
@@ -304,7 +308,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 */
@@ -340,6 +344,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");
@@ -357,6 +363,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);