why are init's arguments wiped ?

Didier Kryn kryn at in2p3.fr
Fri Jan 29 17:10:10 UTC 2016


Le 29/01/2016 17:32, Isaac Dunham a écrit :
> for opt in $#; do
>      case "$opt" in
> 	(*=*) eval "$opt"
> 	;;
>      esac
> done
>
> exec busybox init $@

     Isaac,

     I understand what that the loop sets environment variables that 
init will inherit, but what's the purpose of the $@ at the end. It's now 
useless and init is going to wipe it out anyway. Did I miss something?

Le 29/01/2016 17:50, Nicolas CARRIER a écrit :
> Is it even possible ? Won't it suffer from the lack of proc / sys and 
> dev ? Environment variables setup by init ?
> What's more, there is a risk to spawn multiple processes (eval ?) 
> before init is launched and the previous questions do apply.

     The first command in your script may be 'busybox mount -t proc proc 
/proc' . I don't think you need /sys and /dev. Mounting /sys is as easy 
as 'busybox mount -t sysfs sys /sys'.

     The processes created in the mean time have no consequence: you 
terminate your script with 'exec init'; this does not cause any fork. It 
is the same process which continues with the new init, and still pid1.

     Didier



More information about the busybox mailing list