Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ukma!rutgers!dptg!ulysses!andante!alice!debra From: debra@alice.UUCP (Paul De Bra) Newsgroups: comp.unix.wizards Subject: Re: How does Unix kernel find /bin/sh? Keywords: #!/bin/sh Message-ID: <9831@alice.UUCP> Date: 27 Aug 89 17:06:16 GMT References: <5@minya.UUCP> Reply-To: debra@alice.UUCP () Organization: AT&T, Bell Labs Lines: 26 In article <5@minya.UUCP> jc@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@research.att.com | uunet!research!debra | ------------------------------------------------------