Henrik wrote:
If you omit the #!/bin/bash from child.sh, I suspect
the original bash will
look at the file, recognize it's executable, but
since the file doesn't
specify a new command interpreter, it's equivalent to
". ./child.sh" meaning
the parent script simply sources the child script.
 Not in a new
Interpreter.

Not quite. It's equivalent to "bash ./child.sh" rather than ". ./child.sh".


I sounds plausible, but I am not sure it is excatly like that because a quick 
test did not give me the expected result

After I trid to change test.sh to use the ". ./child.sh" notation, I do not get 
a child process at all, only the process of test.sh

13870 -bash
17820 /bin/bash ./test.sh
17824 sleep 160

So somehow running without "#!/usr/bin/bash" gets me a new process in the same 
interpreter ?

The shell forks, and the child process tries to execute child.sh using execve(). If this succeeds, the arguments you see in ptree show the child script. If it fails (because there is no #! line), the child process interprets the script, but the process args still match those of the parent.

Have a look at shell_execve() in the bash sources for details.

        Scott

--
Scott Rotondo
Principal Engineer, Solaris Security Technologies
President, Trusted Computing Group
Phone/FAX: +1 408 850 3655 (Internal x68278)
_______________________________________________
opensolaris-discuss mailing list
opensolaris-discuss@opensolaris.org

Reply via email to