0

I am currently writing a program in C using Linux in which a parent process creates a child process and then that child process creates another child processes (so three processes total). I have to pipe a string from parent to the first child process and then from the first child process to the child of that process. I am currently piping the string from parent to child using code similar to this (all code not shown):

pipe(pipeArray)

write(pipeArray[1], myString, length);

close(pipeArray[1]);

read(pipeArray[0], FirstProcessString, length+1);

close(pipeArray[0]);

My problem is the second part of of my program in which now I must take the string from the second child process and pipe it all the way up to the first parent process. How do you pipe from the second child process to the original parent process (the first process)? I have tried variations of this code in order to pipe up with no luck and also researched this topic and was not able to find anything helpful.

tshepang
  • 12,111
  • 21
  • 91
  • 136
  • 1
    check out http://stackoverflow.com/questions/6820450/pipes-between-child-processes-in-c as well as http://stackoverflow.com/questions/5225810/is-it-possible-to-have-pipe-between-two-child-processes-created-by-same-parent – Richard Chambers Sep 23 '13 at 15:51
  • Thank you, but I had already looked at those. They are a little different than what I am doing. I have encountered two main problems while doing this program: 1) I need to pipe up from two children down to the parent and 2) I am unsure whether or not I need to create a new pipe and I am unsure how to change my code to do this. Because I had tried creating a new pipe and it did not work. The commands above that I am using worked to pipe downward but I do not understand why they would not work when piping upwards? – Andrew Carroll Sep 23 '13 at 17:56

0 Answers0