File descriptors, including pipes, are duplicated on the fork - the child process ends with the same file descriptor table, including stdin / out / err and pipe, since the parent element was immediately before the fork.
Based on my understanding, the child process created by fork does not pass variables with its parent process.
This is not entirely true: variables are not passed on to variable parents, but the values ββthat the parent had immediately before the fork are now visible to the descendant.
In any case, pipes exist inside the operating system, not inside the process. Thus, data recorded at one end of the pipe becomes visible to any other process containing FD for the other end. (If several processes try to read data, the first process to try to get read() data gets it and any other processes skip.)
duskwuff
source share