Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.unix.wizards Subject: Re: How does Unix kernel find /bin/sh? Keywords: #!/bin/sh Message-ID: <1083@virtech.UUCP> Date: 27 Aug 89 13:47:09 GMT References: <5@minya.UUCP> Organization: Virtual Technologies Inc Lines: 30 In article <5@minya.UUCP>, jc@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 | +-----------------------------------------------------------------------+