[OpenWrt-Devel] [PATCH] procd: delay inittab workers until the tty exists.

John Crispin blogic at openwrt.org
Fri Jan 16 01:31:23 EST 2015


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 <osk at 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;
>      }
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list