Problem with pipes

problem solved.

Add

CLOSE_ALL(fd1);

after line 86 before you recursively call child.