Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Thanks. When a call to execve() finishes, does execve() terminate its process, regardless whehter execve() succeeds or fails? I thought yes, so when execve() fails to execute a shell script, it would terminate the subprocess, and the original shell will have to fork a subprocess to execute the script. Commented Apr 23, 2018 at 12:27
  • No, it doesn’t. Commented Apr 23, 2018 at 18:57
  • Thanks.When a bash script ./test.sh with shebang #! /bin/bash is executed via command ./test.sh, is it actually executed as /bin/bash ./test.sh? If yes, is it correct to expect bash to run execve("/bin/bash", ["/bin/bash", "./test.sh"], ...) = 0? But I run strace -f ./test.sh 2>&1 | less, and only find one call to execve(): execve("./test.sh", ["./test.sh"], [/* 59 vars */]) = 0. Note the difference in the first argument, which is for the executable file. Commented Apr 23, 2018 at 21:14
  • @Tim, see What exactly happens when I execute a file in my shell. Commented Apr 24, 2018 at 4:17