If a process with a tty is specified in inittab, delay the worker process until 
the tty exists.

This allows starting consoles with terminals that get delayed until after procd 
is reads inittab,
and it also allows hotplugging USB-to-serial adapters attached long after 
booting.

Signed-off-by: Owen Kirby <o...@exegin.com>
---
 inittab.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/inittab.c b/inittab.c
index 623103d..73c113f 100644
--- a/inittab.c
+++ b/inittab.c
@@ -99,9 +99,15 @@ static void fork_worker(struct init_action *a)
        if (!a->proc.pid) {
                p = setsid();
- fd = dev_open(a->id);
-               if (fd != -1)
-               {
+               if (a->id) {
+                       struct timespec tm;
+                       tm.tv_sec = a->respawn / 1000;
+                       tm.tv_nsec = (a->respawn % 1000) * 1000000;
+
+                       while ((fd = dev_open(a->id)) == -1)
+                               if (nanosleep(&tm, NULL) == -1)
+                                       exit(-1);
+
                        dup2(fd, STDIN_FILENO);
                        dup2(fd, STDOUT_FILENO);
                        dup2(fd, STDERR_FILENO);
@@ -157,7 +163,7 @@ static void askfirst(struct init_action *a)
 {
        int i;
- if (!dev_exist(a->id) || (console && !strcmp(console, a->id))) {
+       if (console && !strcmp(console, a->id)) {
                DEBUG(4, "Skipping %s\n", a->id);
                return;
        }
--
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to