Don't take it from me, but this might not be possible without writing an apache module or something. You might be well served with using IPC of some sort. If it's simple, you can just use signals to contact a daemon in the background to tell it to fork(). Read the perl manpage on signals first, but it's pretty simple:


# in the daemon
$SIG{'INT'} = \&signal_handler;
sub singnal_handler {
# we don't want to do anything too complex in the handler
# or we risk an ugly death
$fork_now = 1;
}

# then just test $fork_now in the main loop of your daemon
# to fork when it's set (then unset it immediately)


# in the calling process:
kill -2 $pid; # sends SIGINT to $pid.

If you need the daemon to get more complicated information than a simple signal, you should explore other forms of IPC like sockets or SysV message queues and what not. I've used signals with a web board on a daemon which updates semi-static content and things to force it to update or re-read config information and it works quite well.

Hope that helps.


In reply to RE: forking from web by Anonymous Monk
in thread forking from web by cez

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.