http://qs321.pair.com?node_id=409217

etcshadow has asked for the wisdom of the Perl Monks concerning the following question:

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