How does Unix kernel find /bin/sh?

Paul De Bra debra at alice.UUCP
Mon Aug 28 03:06:16 AEST 1989


In article <5 at minya.UUCP> jc at minya.UUCP (John Chambers) writes:
>...
>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).  
>...

Hmm, RTFM doesn't seem to help, and neither the Bach book indeed.
A possible explanation however is that if the Bourne shell wants to
execute it forks off a child which execs. If the exec fails the shell
thinks the file must be a shell script so it again forks off a child
which does not exec /bin/sh because it thinks it already IS /bin/sh.
It just tries to run the script.
So the kernel has nothing to do with it. The shell just doesn't exec
"itself" because it knows it is "itself".

Hope someone can confirm whether this is indeed what's happening?

Paul.
-- 
------------------------------------------------------
|debra at research.att.com   | uunet!research!debra     |
------------------------------------------------------



More information about the Comp.unix.wizards mailing list