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

List:       busybox
Subject:    Re: Best way to use dhcpc / avahi without delaying other init scripts ?
From:       Harald Becker <ralda () gmx ! de>
Date:       2013-04-30 23:47:38
Message-ID: 20130501014738.2a7240e7 () ralda ! gmx ! de
[Download RAW message or body]

Hi Avery !

>The & sign implies the need for a fork anyway.

One fork yes, this is the required fork, but ...

> As far as I know, all modern shells are smart enough to avoid
> double-forking in this case.

Modern shells? You mean like bash? Yes! ... but I'm not sure if Busybox
ash knows about that optimization.

That is ( ... ) forks a subshell with the main shell immediately waiting
until subshell has finished. ( ... ) & forks into background, than
forks again in background to run a subshell. { ... } & forks once to
run the group of commands in the forked shell.

To verify: Use GNU /bin/ps --forest in the examples above. (...)& gives
three shell processes, where {...}& shall only give two shell
processes. Test with bash and Busybox ash and see difference. I did
this with older Busybox versions, but don't think anybody improved
subshell forking in ash.

>:)

Nice to have optimizations, but better to know how to optimize for all
shells, not only modern ones. Small change, big performance hit.

--
Harald
_______________________________________________
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