/bin/sh path search broken

Rob Landley rob at landley.net
Wed Oct 18 16:18:34 UTC 2006


On Tuesday 17 October 2006 7:44 pm, Larry Brigman wrote:
> The only reason I found this problem so quick was that it had happened to me
> on 
> another project that I was using busybox on.  The shell script would
> not find anything
> until proc was mounted.

Unfortunately, Linux has no easy way for a process to re-exec itself.  All 
execs must be done byname (not even by filehandle, you have to feed it the 
syscall a path/filename).  So when you want to fork and have the child 
restart itself from the beginning (freeing allocated memory and closing 
filehandles and all the other cleanup exec does), you have to know where your 
executable lives.

By default standalone shell mode uses /proc/self/exe as the file to exec when 
restarting itself (to run a child process in the standalone shell), but in 
recent releases (1.2.*) under "busybox setting", "general setup", at the end 
of the menu you can configure the path to where the busybox executable lives.

I.E. if you don't have /proc mounted, you have to tell menuconfig where in the 
filesystem the busybox executable will live, or else standalone shell can't 
re-exec itself.

Now that said, if standalone shell fails to exec it should fail over to 
looking in your $PATH for normal symlinks.  Is it not doing that?

Rob
-- 
"Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away." - Antoine de Saint-Exupery



More information about the busybox mailing list