Issue with dup2

I am trying a simple program where the STDOUT from Child process is directed to the Parent process. The program works if I don’t fork multiple times and call the child_process and parent_process in a loop. However, when I put a for loop around the fork and child_process and parent_process, dup2 function returns -1 and… Read More Issue with dup2