<div dir="ltr"><div style>Bzzzzt. Wrong.</div><div style><br></div><div>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).</div>
<div><br></div><div style>And just to backup my claim above - see a more comprehensive response here: <a href="http://stackoverflow.com/a/976087">http://stackoverflow.com/a/976087</a></div></div><div class="gmail_extra">
<br>
<br><div class="gmail_quote">On 4 June 2013 21:43, ronys <span dir="ltr"><<a href="mailto:ronys@gmx.net" target="_blank">ronys@gmx.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Nothing. You're just wasting resources (file descriptors) and making your code a bit harder to understand and maintain.<div><br></div><div>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...).</div>
<div><br></div><div>Rony</div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Tue, Jun 4, 2013 at 2:24 PM, Erez D <span dir="ltr"><<a href="mailto:erez0001@gmail.com" target="_blank">erez0001@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div><div><div><div><div>hello<br><br></div>using the usual pipe()+fork()+dup()+close() to fork a child process and pipe data from and to it,<br>
<br></div><div>I know both the child and parent must close the unused fds.<br>
</div></div><br>why ?<br></div>what if i don't close the unsed fds ?<br><br><br></div>thanks,<br></div>erez.<br><div><div><div><div><br></div></div></div></div></div>
<br></div></div>_______________________________________________<br>
Linux-il mailing list<br>
<a href="mailto:Linux-il@cs.huji.ac.il" target="_blank">Linux-il@cs.huji.ac.il</a><br>
<a href="http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il" target="_blank">http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Ubi dubium, ibi libertas (where there is doubt, there is freedom)<br>
</font></span></div>
<br>_______________________________________________<br>
Linux-il mailing list<br>
<a href="mailto:Linux-il@cs.huji.ac.il">Linux-il@cs.huji.ac.il</a><br>
<a href="http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il" target="_blank">http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">
<a href="http://www.linkedin.com/in/gliderflyer" target="_blank">
<span>
<img src="http://s4.licdn.com/scds/common/u/img/webpromo/btn_viewmy_160x25.png" alt="View my profile on LinkedIn" height="25" width="160">
</span></a></div>
</div>