<div dir="ltr">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><div class="gmail_extra"><div class="gmail_quote"><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></blockquote><div><br></div><div style>And about this one (race conditions) - any two processes using pipes (which have limited buffer size) to talk to each other bi-directionally run the risk of a deadlock if not coded carefully since they can easily reach a point where both of them block on write(2) which will only unblock when the other side read(2)'s and frees up space in the buffer (but the other side is blocked on a write - that's why it's called a "deadlock"). Typical ways to avoid that are to create threads to watch the fd's or use none-blocking IO.</div>
<div style> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">
<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></div>