I've been hired to to extend some system that is essentially a forking server. Parent wait's for a connection, once detected it forks off the child and let's it handle it's business (login, process requests ...).

One of the modifications requested is that they can order it to drop some connection (all connection for one user - as there can be more than one connection/child for one user). As it is in that business, everyone keeps open connections, even if they have nothning to send, and just enquire link commands every x seconds (keep alive ping). The business is SMS providing (wholesale of SMS's).

As it's only the child knowing what user is logged in it, I was thinking of setting a shared memory key to username/id to be dropped, and sending a signal (say SIGUSR1) to program group. Childs would process SIGUSR1 and check if it's their user, and if it is, drop the connection.

But I was also thinking on being able to call functions from/in parent (or child) and pass a few parameters. Existing mechanisms such as pipes seem like a way too complicated as I would need to implement a lot of surounding code. Check for anythnig in the pipe ...

A perlish idea I have to do that, is to set a shared variable to say "function('param1', 234);" and signal the parent/child(s) who would simply EVAL that - would that even work? Anyone used somethnig like that?

Any other, simple way of calling functions from another process, where you "control" (can change code) both sending/receiving sides.

Have you tried freelancing? Check out Scriptlance - I work there. For more info about Scriptlance and freelancing in general check out my home node.

In reply to child and parent process communication by techcode

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.