How does Unix kernel find /bin/sh?

Conor P. Cahill cpcahil at virtech.UUCP
Sun Aug 27 23:47:09 AEST 1989


In article <5 at minya.UUCP>, jc at minya.UUCP (John Chambers) writes:
> The problem is simple:  when I exec a script directly, the kernel
> doesn't run /bin/sh, it runs /bin/bsh! 

This is your problem.  The kernel doesn't interpret your command and
run the shell, the shell does.  The shell realizes that you wish to 
execute a sub shell and just forks without having to re-exec himself.  

> But there seems to be some sort of deal going between the Bourne
> shell and the kernel, so that when bsh starts up, it tells the
> kernel "Don't pay any attention to /bin/sh; I'm the real shell",
> and the kernel believes it.  Does anyone know how this works?  I'd
> like to see if my program can intercede and convince the kernel that
> it's the shell (after all, it *is* /bin/sh).  

Like I said, the kernel plays no part in this it is the shell itself.

> Can someone explain what's going on, and why my imposter shell (hey, 
> maybe that's what "ish" stands for |^) gets invoked correctly in every 
> case except when a script is execed directly?

If you want to bypass this you can change the exec to be 
an exec of "/bin/sh script" and you will get what you want, but not
the way that you want it.

-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.unix.wizards mailing list