exit isn't complicated. Waiting to read a command while busy writing output, in Perl, certainly can be complicated. Given that sockets are being used here, select would likely be a useful solution. But fork is equally useful and likely makes for a simpler solution (well, at least if you aren't using a Perl that emulates fork(), such as non-Cygwin Windows Perl does).

I'd be curious what doesn't work about the presented code. I don't see any obvious problem with it. And I don't see where the failing of the code is described.

Also, what the OP calls the "listening parent" seems to me likely (based on the code and on other parts of the description) to actually be the middle process that is reading (not "listening") while the parent of that middle process is the one listening for new connections to come in (and the middle's child, the grandchild process, is the one writing).

Certainly, the code presented is incomplete. But I fail to imagine a likely problem with the grandparent process that would likely point the OP to the problem being with the code presented.

paulc1976, please describe, precisely, how your code fails to behave as you desired. And please provide more code. Best would be to pare down the other code so that you have a minimalist, self-contained example that others can run to observe how it fails to meet your described desired requirements.

- tye        


In reply to Re^2: Closing socket handle of child process (complicated?) by tye
in thread Closing socket handle of child process by paulc1976

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.