Multi Pipes in C
I have a homework which is writing own shell. so, I try to connect th开发者_C百科ree pipes in c, but I cant. like this
/bin/cat a.txt | /usr/bin/wc -l | /usr/bin/wc -l
Thanks
Remember that each command executes in its own process, each of which inherits the STDIN, STDOUT, and STDERR I/O streams from your shell. So you must create the pipes and redirect them to the I/O streams or each subprocess prior to forking each subprocess.
http://www.scsh.net/docu/scsh-paper/scsh-paper-Z-H-4.html#%_sec_2 Provides an excellent overview of this very process.
精彩评论