inittab: fallback when multiple "console=" is detected
[project/procd.git] / inittab.c
index 2c2270cf68d367bcb882e0467d2bfd2456111daa..73a2174a97b6eb36778c1790e853c9ad18c000e8 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;
@@ -189,8 +192,12 @@ static void askconsole(struct init_action *a)
         * is in the device tree
         */
        tty = get_cmdline_val("console", line, sizeof(line));
-       if (tty == NULL) {
-               tty = get_active_console(line, sizeof(line));
+       if (tty == NULL ||
+           get_cmdline_val_offset("console", line, sizeof(line), 1)) {
+               if (dev_exist("console"))
+                       tty = "console";
+               else
+                       tty = get_active_console(line, sizeof(line));
        }
        if (tty != NULL) {
                split = strchr(tty, ',');
@@ -290,6 +297,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