How to write to stdin of another program (program A -> [stdin]program B)

Hi,
Program A: uses pipe()

I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using:

  • child
    -> dup2(fd[1], STDOUT_FILENO);
    -> execl("/path/PROGRAM B", "PROGRAM B", NULL);

  • parent
    -> char line[100];
    -> read(fd[0], line, 100);

Question:
---------
How to write to stdin of PROGRAM B from PROGRAM A?

  • should I use a different pipe?
  • how to I read stdin in PROGRAM B? using cin?

Thanks in advance,
Vivek

It's against the:

to double posts questions, continue here:

http://www.unix.com/unix-dummies-questions-answers/63311-how-write-stdin-another-program-program-stdin-program-b.html\#post302190772

Thread close