2

I am interested in finding which variant of the exec*() family of functions does the Bash shell use in order to launch programs. For example, the system() function uses execl(), but what does Bash use?

I did some investigation, but I want to double check with everyone if this is the right place in the Bash source code where a command entered from the terminal is executed.

I investigated Bash version 4.2.53, and found a file called execute_cmd.c. In there I observe the following chain of calls:

  1. execute_disk_command()
// I think this is where bash forks a child
pid = make_child (savestring (command_line), async); 
...
exit (shell_execve (command, args, export_env)); 
  1. shell_execve (command, args, env)
// I think this is where the child invokes the new program
execve (command, args, env);

Is the control flow above the right one?

0

1 Answer 1

2

I am not sure why you like to know that, but:

There is only one exec call that is really a syscall: execve()

All other exec*() functions are just library functions that act as frontend to execve(). Using truss(1) or clones will only show you the syscalls unless you use truss -u libc::

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.