Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
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 musing on the Monastery: (5)
As of 2024-04-20 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found