I have never ever done IPC before (that I know of :) ). Lets say I have a program that spawns 2 children.

  • One of the children listens on a socket for data from a server (AF_INET, DGRAM).
  • The other child watches a log (using the tail -f concept -- does NOT use system(tail...)) that gets continually written to.
  • The main module (daemonized already) spawns these two kiddies off. It will react to the work they perform.
  • Now, since the child processes fork(), I still have to keep them in a loop to watch what they spit out, right? ...thing is is that I would then have two different loops of which neither are really related to each other so I don't want to nest the loops that they are in. Am I correct?

    eg.

  • This will not work because the second loop won't get used until the first one is over which means that it will never get called...
  • main: fork(child1); fork(child2); # endless loop until signal caught from # shell (child1): loop(read from child1) { react } # endless loop until signal caught from # shell (child2): loop(read from child2) { react } main END:
  • This next loop will not work because the innermost loop will be the only loop running so the outer loop will never get munched on.
  • main: fork(child1); fork(child2); # endless loop until signal caught from # shell (child1): loop(read from child1) { react # endless loop until signal caught from # shell (child2): loop(read from child2) { react } } main END:
  • I have to be able to do something like this:
    main: fork(child1); fork(child2); # endless loop until signal caught from # shell (child1): loop(true) { check child1 # call sub reacting from input; check child2 # call sub reacting from input; } # loop until a signal is caught. END main:
    How would this be done? I have read through the Perl cookbook on IPC and I can't seem to pick up how I would do something like this using the information provided in their examples and documentation. I have read perldoc perlipc but I admit that I am so new to this stuff that a lot of it is jargon that is over my head.

    I have already written the meat of the three modules. This is the biggest part that stumps me.

    I think what I really need is some documentation that doesn't talk above my head :( One of these days I will understand the high-talk but I have the terrible problem where I can get lost in the words very quickly. If anyone has a site or something out there that is easily read I would love that. I also learn quite quickly from source code. If there is some code out there that would give me an idea of how to do what I am trying to do that would be very helpful as well.

    Thanks guys.

    ----------
    - Jim


    In reply to A challenge...at least for me. by snafu

    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.