1

Is it necessary to close the opposite ends of a pipe in parent and child?

view story
linux-howto

http://unix.stackexchange.com – The following is a general pipe() usage example: int fd[2]; pipe(fd); if((childpid = fork()) == -1) { perror("fork"); exit(1); } if(childpid == 0) { /* Child process closes up input side of pipe */ close(fd[0]); ////.....some code....//// exit(0); } else { /* Parent process closes up output side of pipe */ close(fd[1]); ////.....some code....//// } What I want to know is that whether the call to close(fd[0]) in the child and close(fd[1]) in the parent process is necessary. What happens if I don't close() them and (HowTos)