task3.c reworked without using pipe2()