chiark / gitweb /
relicense to LGPLv2.1 (with exceptions)
[elogind.git] / src / shutdown.c
index d157e0fbfeaf4db91cea33666f9e2ab5c59c3633..cd478b0349901e6a8762bea0adcc6f8adc190f73 100644 (file)
@@ -6,16 +6,16 @@
   Copyright 2010 ProFUSION embedded systems
 
   systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
   (at your option) any later version.
 
   systemd is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  General Public License for more details.
+  Lesser General Public License for more details.
 
-  You should have received a copy of the GNU General Public License
+  You should have received a copy of the GNU Lesser General Public License
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
@@ -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
@@ -306,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 */
@@ -342,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");
@@ -359,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);