procd: service_stop_all: also kill inittab actions
authorDaniel Golle <daniel@makrotopia.org>
Tue, 16 Nov 2021 03:06:36 +0000 (03:06 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 23 Nov 2021 13:56:52 +0000 (13:56 +0000)
Also send SIGKILL to all actions spawned by inittab.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
inittab.c
procd.h
service/service.c

index b2ffc9a25e5fc69aa6a581002331c3ab93c1cc3f..128268a03fdbd2163210007a555a8bfe2ef82dee 100644 (file)
--- a/inittab.c
+++ b/inittab.c
@@ -123,6 +123,9 @@ static void child_exit(struct uloop_process *proc, int ret)
        DEBUG(4, "pid:%d, exitcode:%d\n", proc->pid, ret);
        proc->pid = 0;
 
+       if (a->respawn < 0)
+               return;
+
        if (!dev_exist(a->id)) {
                DEBUG(4, "Skipping respawn: device '%s' does not exist anymore\n", a->id);
                return;
@@ -293,6 +296,17 @@ void procd_inittab_run(const char *handler)
                }
 }
 
+void procd_inittab_kill(void)
+{
+       struct init_action *a;
+
+       list_for_each_entry(a, &actions, list) {
+               a->respawn = -1;
+               if (a->proc.pid)
+                       kill(a->proc.pid, SIGKILL);
+       }
+}
+
 void procd_inittab(void)
 {
 #define LINE_LEN       128
diff --git a/procd.h b/procd.h
index caaf3e452997ee871803e925cc651bccd8a42400..fd29a128170ffcd7dd44a1aab5a7ce59cb917b86 100644 (file)
--- a/procd.h
+++ b/procd.h
@@ -43,6 +43,7 @@ void procd_signal(void);
 void procd_signal_preinit(void);
 void procd_inittab(void);
 void procd_inittab_run(const char *action);
+void procd_inittab_kill(void);
 void procd_bcast_event(char *event, struct blob_attr *msg);
 
 struct trigger;
index 5c66fb21c57ef82bcdfea2d5465beec1dcb1e83a..bb3e1216ec18bd0e5c1121056572bdb0cf5537cf 100644 (file)
@@ -676,7 +676,7 @@ service_stop_all(void)
 
        service_avl_stop_all(&containers, &term_timeout);
        service_avl_stop_all(&services, &term_timeout);
-       /* ToDo: inittab */
+       procd_inittab_kill();
 
        sleep(term_timeout);
 }