in reply to starting/stopping a daemon from Apache/mod_perl?

I see no really clean way to do this from mod_perl. The closest I can see would be to install a PerlChildExitHandler - as noted in Chapter 7 of the "eagle" book, "Writing Apache Modules with Perl and C" - but this runs each time a child apache process ends, so it would still have to check that it was the last child process left up, (because shutdown is not the only reason a process goes down), then kill your other daemon. And I'm not sure what a "child" process means, if anything, in the Win32 environment.

Update: If the child processes are put down in parallel during shutdown, (eg. they're all sent a signal as members of a process group) there could be a race, where your PerlChildExitHandler still sees other processes up when in fact they are all coming down. Your less-desired solution of having the other daemon check for the Apache process each time it loops may be the safest way to do this.

--Bob Niederman, http://bob-n.com
  • Comment on Re: starting/stopping a daemon from Apache/mod_perl?

Replies are listed 'Best First'.
Re: Re: starting/stopping a daemon from Apache/mod_perl?
by sri (Vicar) on Jul 12, 2003 at 22:38 UTC
    Yes, PerlChildExitHandler would be a solution if i could make sure that the child gets killed because of a server shutdown.