Pipes...

Paul Jackson pj at sam.wpd.sgi.com
Sun May 12 11:06:24 AEST 1991


In article <4250.on.Fri,.10.May.91.20:53:34.EDT. at sct60a.sunyct.edu>,
sweetmr at SCT60A.SUNYCT.EDU (michael sweet) writes:
|> 
|> In a project I am working on, I want to fork and exec another process with
|> pipes to *both* the standard input and output of the new process.

Only call pipe once, not twice.  The pipe(2) system call provides
a pair of file descriptors, one good for reading and one for writing.
And after duping them in the child to its stdin/stdout, close the
file descriptors that you got from pipe.

See an example, using the command "cat" instead of "tar"
on page 130, Section 6.3, of Marc J. Rochind's "Advanced
Unix Programming", Prentice Hall,1985.

-- 

				I won't rest till it's the best ...
				Software Production Engineer
				Paul Jackson (pj at wpd.sgi.com), x1373



More information about the Comp.sys.sgi mailing list