[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH 01/19] init: avoid loop when opening tty
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2012-09-29 14:38:31
Message-ID: 201209291638.31862.vda.linux () googlemail ! com
[Download RAW message or body]

On Tuesday 25 September 2012 14:06, Florian Fainelli wrote:
> From: Imre Kaloz <kaloz@openwrt.org>
> 
> Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
> ---
>  init/init.c |    9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/init/init.c b/init/init.c
> index 7248946..4bae1c4 100644
> --- a/init/init.c
> +++ b/init/init.c
> @@ -586,8 +586,11 @@ static void run_actions(int action_type)
>  			/* Only run stuff with pid == 0. If pid != 0,
>  			 * it is already running
>  			 */
> -			if (a->pid == 0)
> +			if (a->pid == 0) {
> +				if (a->terminal[0] && access(a->terminal, R_OK | W_OK))
> +					continue;
>  				a->pid = run(a);
> +			}
>  		}
>  	}
>  }

The looping will still be there: init will retry it in one second.

The only thing you save here is [v]fork in run():

static pid_t run(const struct init_action *a)
{
        if (BB_MMU && (a->action_type & ASKFIRST))
                pid = fork();
        else
                pid = vfork();
...
        /* Child */
...
        /* Open the new terminal device */
        if (!open_stdio_to_tty(a->terminal))
                _exit(EXIT_FAILURE);

The open will fail, child will exit, and we will try again
in one second.

Are you trying merely to avoid forking in this case?

-- 
vda

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic