Take the 2-minute tour ×  I'm trying to understand the usage of
pipe.  A parent process will pipe and if the parent forks, the
child process will inherit the pipe. So now we hae a direct link
to the child process and they can communicate?  I get lost when
we start to close pipes and redirect pipes. Does anyone have a
good explanation on closing pipes and redirecting pipes?  Thank
you in-advance.  share|improve this question  5 Answers 5  up
vote 6 down vote accepted  Here's the deal.    1. A pipe is a
software abstraction, that has two ends, each one a fd. Whatever
you write on at one end (write fd), you can read off the other
end (read fd).   2. The trick in using a pipe is that you switch
the stdin of some process with the read fd of the pipe. Now, you
can write to the write fd of the pipe, and when the other
process reads what he thinks is his stdin, he actually reads the
read fd of the pipe (and gets your data).   3. For two way
communication, you can get another pipe, and switch the stdout
of the process