<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 6, 2013 at 5:45 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"><div class=""><div class="h5">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:29 PM, E.S. Rosenberg <<a href="mailto:esr%2Blinux-il@g.jct.ac.il">esr+linux-il@g.jct.ac.il</a>><br>
> wrote:<br>
>><br>
>> re:all, forgot to change my from field.<br>
>><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<br>
>> >> >> 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<br>
>> >> >> for<br>
>> >> >> this<br>
>> >> >> possibility). This means that should one process die unexpectedly,<br>
>> >> >> 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<br>
>> >> > 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<br>
>> > their<br>
>> > "write" side already closed.<br>
>> That's why we are able to check if we are a child or a parent with the<br>
>> fork() function.<br>
><br>
> that doesn't help<br>
><br>
> sunday: parent creates a pipe<br>
> monday: parent forks for child 1. parent closes write. child 1 closes read.<br>
> child 1 now can write and parent can read.<br>
> tuesday: parent forks for child 2. child 2 can not write - pipe already<br>
> close by parent on monday.<br>
</div></div>Seriously?<br></blockquote><div>yes, Seriously!</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Just have the parent request another child from the child,</blockquote><div>can't do - i do not have the source of the child. ( i do fork+exec )<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
or create a<br>
child who's specific task is spawning the worker children,<br></blockquote><div>why complicate things ? such a child takes a lot more resource than a non-closed side of a pipe<br></div><div>also you have just moved the problem, instead of the parent having a non closed write side, you have this special child with a non closed write side.<br>
</div><div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">or any of<br>
the other many solutions to this problem.<br></blockquote><div>any thing simpler that "not closing a the 'write' side of a pipe in the parent" ? <br></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=""><div class="h5">><br>
>><br>
>> >><br>
>> >> ><br>
>> >> >><br>
>> >> >> Best practices are there for a reason, despite what others here<br>
>> >> >> 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>
><br>
><br>
</div></div></blockquote></div><br></div></div>