add respawn support
authorJohn Crispin <blogic@openwrt.org>
Mon, 24 Jun 2013 16:31:51 +0000 (18:31 +0200)
committerJohn Crispin <blogic@openwrt.org>
Mon, 24 Jun 2013 16:31:51 +0000 (18:31 +0200)
https://dev.openwrt.org/ticket/13751

Signed-off-by: John Crispin <blogic@openwrt.org>
inittab.c
state.c

index 2ed1395d884423134d205fd948f385987885e2c5..686d3891655fc01c7314b07083482abf06fb60e9 100644 (file)
--- a/inittab.c
+++ b/inittab.c
@@ -175,6 +175,15 @@ err_out:
        regfree(&pat_cmdline);
 }
 
+static void rcrespawn(struct init_action *a)
+{
+       a->tout.cb = respawn;
+       a->respawn = 500;
+
+       a->proc.cb = child_exit;
+       fork_worker(a);
+}
+
 static struct init_handler handlers[] = {
        {
                .name = "sysinit",
@@ -190,6 +199,10 @@ static struct init_handler handlers[] = {
                .name = "askconsole",
                .cb = askconsole,
                .multi = 1,
+       }, {
+               .name = "respawn",
+               .cb = rcrespawn,
+               .multi = 1,
        }
 };
 
diff --git a/state.c b/state.c
index 8fe931eae5deeac85ee0b2fd19445815ef00bf5d..618d75879051a3e042da6763f196a11e599a59d1 100644 (file)
--- a/state.c
+++ b/state.c
@@ -50,6 +50,7 @@ static void state_enter(void)
                log_init();
                procd_connect_ubus();
                procd_inittab();
+               procd_inittab_run("respawn");
                procd_inittab_run("askconsole");
                procd_inittab_run("askfirst");
                procd_inittab_run("sysinit");