Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I am trying to set up a mod_perl process such that it can fork out a child which can survive the restart of the server. I figured this would be easy enough with minor modifications on the double-fork method, but it doesn't seem to be working. I've tried this:
use Apache::SubProcess; my $pid = fork; if (defined $pid && !$pid) { Apache->request->cleanup_for_exec(); $pid = fork; if (defined $pid && !$pid) { close STDERR; close STDIN; close STDOUT; sleep 100; CORE::exit; } else { CORE::exit; } } waitpid($pid, 0);
Now this does successfuly sever the grandchild from the mod_perl process, inasmuch as its parent process id becomes 1 (child of init). Still, when the mod_perl process gets killed, it still kills the grandchild.

However, if I do the same thing in a perl (not mod_perl) process, minus the Apache::SubProcess and cleanup_for_exec, then it works fine. Killing the grandparent perl process has no impact on the grandchild.

So this made me curious if this was some sort of issue with the apache parent process keeping a record of processes in its process group. I fired up the apache server status page, and it seems to have no clue about the grandchild process. So I don't know why it would be a deliberate signal propogation by the apache server to processes it was only ever briefly associated with.

Of course, there are other ways to accomplish what I want to (via exec'ing), but I'd like to work this out. Anyway, got any ideas on how to do this? Thanks.

------------ :Wq Not an editor command: Wq

In reply to Keeping grandchild alive when mod_perl process is killed by etcshadow

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others taking refuge in the Monastery: (3)
    As of 2024-07-16 06:56 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?
      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.