chiark / gitweb /
sleep: implement suspend/hibernate as first class targets
[elogind.git] / src / core / shutdown.c
index cd478b0349901e6a8762bea0adcc6f8adc190f73..a8dfe2614f204e7d588686406ff06297a49b74d9 100644 (file)
@@ -309,6 +309,7 @@ int main(int argc, char *argv[]) {
         unsigned retries;
         bool need_umount = true, need_swapoff = true, need_loop_detach = true, need_dm_detach = true;
         bool killed_everbody = false, in_container, use_watchdog = false;
+        char *arguments[3];
 
         log_parse_environment();
         log_set_target(LOG_TARGET_CONSOLE); /* syslog will die if not gone yet */
@@ -347,8 +348,7 @@ int main(int argc, char *argv[]) {
         use_watchdog = !!getenv("WATCHDOG_USEC");
 
         /* lock us into memory */
-        if (mlockall(MCL_CURRENT|MCL_FUTURE) != 0)
-                log_warning("Cannot lock process memory: %m");
+        mlockall(MCL_CURRENT|MCL_FUTURE);
 
         log_info("Sending SIGTERM to remaining processes...");
         send_signal(SIGTERM);
@@ -356,8 +356,10 @@ int main(int argc, char *argv[]) {
         log_info("Sending SIGKILL to remaining processes...");
         send_signal(SIGKILL);
 
-        if (in_container)
+        if (in_container) {
                 need_swapoff = false;
+                need_dm_detach = false;
+        }
 
         /* Unmount all mountpoints, swaps, and loopback devices */
         for (retries = 0; retries < FINALIZE_ATTEMPTS; retries++) {
@@ -441,7 +443,10 @@ int main(int argc, char *argv[]) {
         if (retries >= FINALIZE_ATTEMPTS)
                 log_error("Too many iterations, giving up.");
 
-        execute_directory(SYSTEM_SHUTDOWN_PATH, NULL, NULL);
+        arguments[0] = NULL;
+        arguments[1] = argv[1];
+        arguments[2] = NULL;
+        execute_directory(SYSTEM_SHUTDOWN_PATH, NULL, arguments);
 
         /* If we are in a container, just exit, this will kill our
          * container for good. */