0

I am trying to execute to child processes(fork(2)) using the stdout from the first as stdin for the secound. (like ./first.o | ./sec.o)

I am already able to pipe when I am executing one process (like ./first.o < in.txt > out.txt). Here i am using open(2) and dup2()to redirect the stdin and stdout to a file.

But how am I able to use stdout from one process as stdin from another?

Thanks in advance!

mstranne
  • 78
  • 12
  • 1
    `man popen`, `man pipe`. – Eugene Sh. Nov 03 '16 at 13:31
  • 2
    Before `fork()`ing, create a pipe via `pipe()`. In the (each) child process, dupe the appropriate end of the pipe onto the appropriate standard stream, and close the other end. If the parent process is not one of those using the pipe, then it should close its copies of *both* pipe ends, but only after forking both children. – John Bollinger Nov 03 '16 at 13:34

0 Answers0