Bzzzzt. Wrong. If the unused side of the pipe is left open by the process which doesn't read it then it will be considered as "open" even if the other side closed it, therefore preventing the reading process from receiving the EOF mark (read(2) returning zero bytes).
And just to backup my claim above - see a more comprehensive response here: http://stackoverflow.com/a/976087 On 4 June 2013 21:43, ronys <[email protected]> wrote: > 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 <[email protected]> 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 >> [email protected] >> 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 > [email protected] > http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il > > -- [image: View my profile on LinkedIn] <http://www.linkedin.com/in/gliderflyer>
_______________________________________________ Linux-il mailing list [email protected] http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
