I have a simple doubt on execution of the command ls
. As per my understanding from the research I have done on the internet, I understood the below points.
When we type ls command shell interprets that command.
Then the shell process forks and creates the child process & the parent(shell) executes the
wait()
system call, effectively putting itself to sleep until the child exits.Child process inherits all the open file descriptors and the environment.
Then The child process executes an
exec()
of the ls program. This reads the ls program from its program file on disk into the existing [child] process.When the ls program runs to completion it calls
exit()
and it sends a signal to its parent indicating the child has terminated.
My doubt starts from here onwards,as soon as ls finishes its tasks ,does it sends the result back to the parent process or it just itself displays the output to the screen?. If it sends the o/p back to parent, then is it using pipe()
implicitly?