Forking in postconfig stage

Oliver Frommel <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
Hi there,

I'd like to know if it's possible to fork an infinite loop in the postconfig stage of the Apache lifecycle. I am trying to do it in a file that I 'use' in the startup.pl that in turn is called by PerlPostConfigRequire. The fork code I am using is almost the same as the "Complete fork example" from the book, however I had to remove all references to the Apache request $r because it is not available at this stage. In the child process I am creating data that is exposed to other requests via IPC::Shareable, but the requests just seem to hang. 

The code looks like this:

startup.pl:
...
  use Datastore::Cache ( );
...

Datastore/Cache.pm:
...
  if ($kid) {
    ...
  } else {
      tie $H, 'IPC::Shareable', 'Test', {create => 1, mode => 0666};

      while(1) {
        my $rnd = rand(5);
        $H = $rnd;
        sleep(60);
      }
  }


As you can see, the general problem I am trying to solve is the global creation of some data that is subject to global change (not dependent on requests) but is available to all requests on a specific URL. Maybe there better ways of achieving my general goal than forking?

Thanks for your help
Oliver
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.