chiark / gitweb /
core: make sure to always go through both SIGTERM and SIGKILL states of units
authorLennart Poettering <lennart@poettering.net>
Wed, 29 Jan 2014 13:58:04 +0000 (14:58 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 29 Jan 2014 16:46:47 +0000 (17:46 +0100)
Given that we now have KillMode=mixed where SIGTERM might kill a smaller
set than SIGKILL we need to make sure to always go explicitly throught
the SIGKILL state to get the right end result.

src/core/mount.c
src/core/scope.c
src/core/service.c
src/core/socket.c
src/core/swap.c

index 90da88382606593d2c38d51c4b42c42b10bc76f3..45c0040bd1e0541f30086518b748aa6fc9b4d08d 100644 (file)
@@ -854,8 +854,14 @@ static void mount_enter_signal(Mount *m, MountState state, MountResult f) {
                         goto fail;
 
                 mount_set_state(m, state);
-        } else if (state == MOUNT_REMOUNTING_SIGTERM || state == MOUNT_REMOUNTING_SIGKILL)
+        } else if (state == MOUNT_REMOUNTING_SIGTERM)
+                mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, MOUNT_SUCCESS);
+        else if (state == MOUNT_REMOUNTING_SIGKILL)
                 mount_enter_mounted(m, MOUNT_SUCCESS);
+        else if (state == MOUNT_MOUNTING_SIGTERM)
+                mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, MOUNT_SUCCESS);
+        else if (state == MOUNT_UNMOUNTING_SIGTERM)
+                mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, MOUNT_SUCCESS);
         else
                 mount_enter_dead(m, MOUNT_SUCCESS);
 
index 87983f6b1746aa9537b01bb0689afa5252d49dd8..5beb4f80c427c65ed8d0588379ef92e34cceb5ed 100644 (file)
@@ -238,7 +238,9 @@ static void scope_enter_signal(Scope *s, ScopeState state, ScopeResult f) {
                         goto fail;
 
                 scope_set_state(s, state);
-        } else
+        } else if (state == SCOPE_STOP_SIGTERM)
+                scope_enter_signal(s, SCOPE_STOP_SIGKILL, SCOPE_SUCCESS);
+        else
                 scope_enter_dead(s, SCOPE_SUCCESS);
 
         return;
index 1ec2e51fc2a927136f551e1ec8873186224b7fb3..0542eae023c18b731c675db3a8d76e3c42c69220 100644 (file)
@@ -1913,10 +1913,9 @@ static void service_enter_stop_post(Service *s, ServiceResult f) {
                 if (r < 0)
                         goto fail;
 
-
                 service_set_state(s, SERVICE_STOP_POST);
         } else
-                service_enter_dead(s, SERVICE_SUCCESS, true);
+                service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_SUCCESS);
 
         return;
 
@@ -1942,6 +1941,7 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f
                         s->main_pid,
                         s->control_pid,
                         s->main_pid_alien);
+
         if (r < 0)
                 goto fail;
 
@@ -1953,8 +1953,12 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f
                 }
 
                 service_set_state(s, state);
-        } else if (state == SERVICE_STOP_SIGTERM || state == SERVICE_STOP_SIGKILL)
+        } else if (state == SERVICE_STOP_SIGTERM)
+                service_enter_signal(s, SERVICE_STOP_SIGKILL, SERVICE_SUCCESS);
+        else if (state == SERVICE_STOP_SIGKILL)
                 service_enter_stop_post(s, SERVICE_SUCCESS);
+        else if (state == SERVICE_FINAL_SIGTERM)
+                service_enter_signal(s, SERVICE_FINAL_SIGKILL, SERVICE_SUCCESS);
         else
                 service_enter_dead(s, SERVICE_SUCCESS, true);
 
index 7eac0eb66de22a7489dd76dc9a05fefde774581d..5f16493bc224d167437ea439a725ee29bbdc60cf 100644 (file)
@@ -1344,8 +1344,12 @@ static void socket_enter_signal(Socket *s, SocketState state, SocketResult f) {
                         goto fail;
 
                 socket_set_state(s, state);
-        } else if (state == SOCKET_STOP_PRE_SIGTERM || state == SOCKET_STOP_PRE_SIGKILL)
+        } else if (state == SOCKET_STOP_PRE_SIGTERM)
+                socket_enter_signal(s, SOCKET_STOP_PRE_SIGKILL, SOCKET_SUCCESS);
+        else if (state == SOCKET_STOP_PRE_SIGKILL)
                 socket_enter_stop_post(s, SOCKET_SUCCESS);
+        else if (state == SOCKET_FINAL_SIGTERM)
+                socket_enter_signal(s, SOCKET_FINAL_SIGKILL, SOCKET_SUCCESS);
         else
                 socket_enter_dead(s, SOCKET_SUCCESS);
 
index 26141e6a33a643db721e1554d36c126b6d9c149c..d53cabef2a5281a66c3ebabef9ecf6033e310b39 100644 (file)
@@ -712,7 +712,11 @@ static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) {
                         goto fail;
 
                 swap_set_state(s, state);
-        } else
+        } else if (state == SWAP_ACTIVATING_SIGTERM)
+                swap_enter_signal(s, SWAP_ACTIVATING_SIGKILL, SWAP_SUCCESS);
+        else if (state == SWAP_DEACTIVATING_SIGTERM)
+                swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, SWAP_SUCCESS);
+        else
                 swap_enter_dead(s, SWAP_SUCCESS);
 
         return;