chiark / gitweb /
service: properly handle if the main process is down and we wait for the cgroup to...
[elogind.git] / src / service.c
index 85dd5d4175536d3f87f96fa917180932b574f3ca..94f2f37afc1c15ce74da44ccac4b4ed71bfed7f7 100644 (file)
@@ -1620,7 +1620,7 @@ static void service_enter_signal(Service *s, ServiceState state, bool success) {
                         if ((r = cgroup_bonding_kill_list(s->meta.cgroup_bondings, sig, pid_set)) < 0) {
                                 if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
                                         log_warning("Failed to kill control group: %s", strerror(-r));
-                        } else
+                        } else if (r > 0)
                                 wait_for_exit = true;
 
                         set_free(pid_set);
@@ -2572,6 +2572,20 @@ static void service_cgroup_notify_event(Unit *u) {
                 service_enter_running(s, true);
                 break;
 
+        case SERVICE_STOP_SIGTERM:
+        case SERVICE_STOP_SIGKILL:
+                if (main_pid_good(s) <= 0 && !control_pid_good(s))
+                        service_enter_stop_post(s, true);
+
+                break;
+
+        case SERVICE_FINAL_SIGTERM:
+        case SERVICE_FINAL_SIGKILL:
+                if (main_pid_good(s) <= 0 && !control_pid_good(s))
+                        service_enter_dead(s, true, true);
+
+                break;
+
         default:
                 ;
         }