Re: [OpenWrt-Devel] [PATCH] procd: delay inittab workers until the tty exists.
Okay, I'll rewrite it. However: Is it polling for the existence of the tty device that is unacceptable (would a solution using uloop_timeout_set() be okay?), or would I need to process hotplug events from the kernel? Thanks, Owen On 15-01-15 10:31 PM, John Crispin wrote: nack, using magic delays is a no go On 16/01/2015 04:15, Owen Kirby wrote: 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) * 100; + +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; } ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] procd: delay inittab workers until the tty exists.
On 16/01/2015 21:19, Owen Kirby wrote: Okay, I'll rewrite it. However: Is it polling for the existence of the tty device that is unacceptable (would a solution using uloop_timeout_set() be okay?), or would I need to process hotplug events from the kernel? use hotplug events please Thanks, Owen On 15-01-15 10:31 PM, John Crispin wrote: nack, using magic delays is a no go On 16/01/2015 04:15, Owen Kirby wrote: 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) * 100; + +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; } ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] procd: delay inittab workers until the tty exists.
nack, using magic delays is a no go On 16/01/2015 04:15, Owen Kirby wrote: 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) * 100; + +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; } ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] procd: delay inittab workers until the tty exists.
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) * 100; + + 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