]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/core/slice.c
core: add IgnoreOnSoftReboot= unit option
[thirdparty/systemd.git] / src / core / slice.c
index 490aabfd35ebe4ad3ede038030d1aafe53424256..069bfe1ea8901de2ac3e3ed5b21e672d6b58e7cd 100644 (file)
@@ -64,22 +64,22 @@ static int slice_add_parent_slice(Slice *s) {
 }
 
 static int slice_add_default_dependencies(Slice *s) {
-        int r;
-
         assert(s);
 
         if (!UNIT(s)->default_dependencies)
                 return 0;
 
         /* Make sure slices are unloaded on shutdown */
-        r = unit_add_two_dependencies_by_name(
-                        UNIT(s),
-                        UNIT_BEFORE, UNIT_CONFLICTS,
-                        SPECIAL_SHUTDOWN_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
-        if (r < 0)
-                return r;
-
-        return 0;
+        if (!UNIT(s)->ignore_on_soft_reboot)
+                return unit_add_two_dependencies_by_name(
+                                UNIT(s),
+                                UNIT_BEFORE, UNIT_CONFLICTS,
+                                SPECIAL_SHUTDOWN_TARGET, true,
+                                UNIT_DEPENDENCY_DEFAULT);
+
+        /* Unless we are meant to survive soft reboot, in which case we need to conflict with
+         * non-soft-reboot targets. */
+        return unit_add_dependencies_on_real_shutdown_targets(UNIT(s));
 }
 
 static int slice_verify(Slice *s) {