Nothing. You're just wasting resources (file descriptors) and making your code a bit harder to understand and maintain.
Note that for pipe(), you can use both fds at both ends of the pipe, but it's very easy to get into a race condition.Better to open a pair of pipes, one for each direction (of course, you now need to worry about deadlocks...). Rony On Tue, Jun 4, 2013 at 2:24 PM, Erez D <erez0...@gmail.com> wrote: > hello > > using the usual pipe()+fork()+dup()+close() to fork a child process and > pipe data from and to it, > > I know both the child and parent must close the unused fds. > > why ? > what if i don't close the unsed fds ? > > > thanks, > erez. > > > _______________________________________________ > Linux-il mailing list > Linux-il@cs.huji.ac.il > http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il > > -- Ubi dubium, ibi libertas (where there is doubt, there is freedom)
_______________________________________________ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il