chiark / gitweb /
container: when shutting down in a container don't detach loop devices
[elogind.git] / src / core / main.c
index 6f6b565d68d9d5424bfaa3ccea2f9986347de8a6..87cb4ffb5cc0fae990443bd7813a5ebaf1d8d707 100644 (file)
@@ -51,6 +51,7 @@
 #include "path-util.h"
 #include "switch-root.h"
 #include "capability.h"
+#include "killall.h"
 
 #include "mount-setup.h"
 #include "loopback-setup.h"
@@ -1676,6 +1677,11 @@ finish:
                 make_console_stdio();
 
                 if (switch_root_dir) {
+                        /* Kill all remaining processes from the initrd */
+                        broadcast_signal(SIGTERM);
+                        broadcast_signal(SIGKILL);
+
+                        /* And switch root */
                         r = switch_root(switch_root_dir);
                         if (r < 0)
                                 log_error("Failed to switch root, ignoring: %s", strerror(-r));