This question already has an answer here:

When ever we execute a command say ls -l, a new shell is spawned with fork() and execve() executes your command. Now my question is when this thing complete and child shell shutdowns how is the output passed to the parent shell which shows it. Does child writes the STDOUT of parent shell? What exactly happens here?

marked as duplicate by Stephen Kitt bash Apr 13 at 8:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Browse other questions tagged or ask your own question.