Suppose I have process foo and executable bar. foo calls fork() and now I have two, call them foo_parent and foo_child.
- foo_parent calls wait()
- foo_child calls execvp([stuff to run bar]);
I don't quite understand what happens to foo_child/bar. Is foo_child overwritten in memory with bar? Is a new bar process started and given foo_child's pid? Is bar a child of foo_child and foo_child just passes the return on to foo_parent?
I know that when foo_parent gets the exit status after wait, it's the result of bar's exit() call, but I don't have a good grasp of what's happening "under the hood," as it were.