<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 6, 2013 at 5:29 PM, E.S. Rosenberg <span dir="ltr"><<a href="mailto:esr+linux-il@g.jct.ac.il" target="_blank">esr+linux-il@g.jct.ac.il</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">re:all, forgot to change my from field.<br>
<div class=""><div class="h5"><br>
2013/6/6 Erez D <<a href="mailto:erez0001@gmail.com">erez0001@gmail.com</a>>:<br>
><br>
><br>
><br>
> On Thu, Jun 6, 2013 at 5:04 PM, E.S. Rosenberg <<a href="mailto:esr@g.jct.ac.il">esr@g.jct.ac.il</a>> wrote:<br>
>><br>
>> 2013/6/6 Erez D <<a href="mailto:erez0001@gmail.com">erez0001@gmail.com</a>>:<br>
>> ><br>
>> ><br>
>> ><br>
>> > On Tue, Jun 4, 2013 at 6:09 PM, Shachar Shemesh <<a href="mailto:shachar@shemesh.biz">shachar@shemesh.biz</a>><br>
>> > wrote:<br>
>> >><br>
>> >> On 04/06/13 15:28, Erez D wrote:<br>
>> >><br>
>> >> thanks,<br>
>> >><br>
>> >> so i guess if i use unidirectional connection, and the reader does not<br>
>> >> expect to get an EOF()<br>
>> >> thank i'm safe.<br>
>> >><br>
>> >> Why are you so keen on doing it wrong?<br>
>> >><br>
>> >> No, you are not safe. If the child process dies because of a<br>
>> >> segmentation<br>
>> >> fault (or whatever), the parent will notice this through the EOF<br>
>> >> received (I<br>
>> >> am assuming here, since you couldn't be bothered with closing a file<br>
>> >> descriptor, that you did not install a SIGCHLD handler to monitor for<br>
>> >> this<br>
>> >> possibility). This means that should one process die unexpectedly, the<br>
>> >> other<br>
>> >> will hang forever.<br>
>> ><br>
>> > it's not a matter of being bothered. closing a file has it's<br>
>> > implications<br>
>> ><br>
>> > 1. close the file for one thread closes for all<br>
>> thread and fork are 2 very different things, best practice for fork<br>
>> ('full' children, I think everyone understands fork() when you say<br>
>> child) is to close, when using threads that is I believe not the case.<br>
>> > 2. what if i want later children using the same pipe, as in all childs<br>
>> > write<br>
>> > to same pipe read by parent...<br>
>> so the children are all closing the read end and the parent only<br>
>> closes write, where is the problem?<br>
><br>
> if the parent closes the "write" side, then new forked children have their<br>
> "write" side already closed.<br>
</div></div><div class="im">That's why we are able to check if we are a child or a parent with the<br>
fork() function.<br></div></blockquote><div>that doesn't help<br><br></div><div>sunday: parent creates a pipe<br>monday: parent forks for child 1. parent closes write. child 1 closes read. child 1 now can write and parent can read.<br>
</div>tuesday: parent forks for child 2. child 2 can not write - pipe already close by parent on monday.<br></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im">
>><br>
>> ><br>
>> >><br>
</div><div class=""><div class="h5">>> >> Best practices are there for a reason, despite what others here might<br>
>> >> have<br>
>> >> you think.<br>
>> >><br>
>> >> Shachar<br>
>> ><br>
>> ><br>
>> ><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>
><br>
><br>
</div></div></blockquote></div><br></div></div>