After investigating deeper into a hanging detection problem, I understood
that I can quite easily write a monitor that will detect these processes
and kill them off. I wrote a module Apache::SafeHang with help of
Apache::Scoreboard that should solve the problem.

The only problem I have with this module, is that it should be forked from
the main process after the server has completed the configuration. I've
tried to fork it during the startup (from startup.pl), but then I don't
get a valid Apache::Scoreboard image, so it's like starting it from shell.
Is it possible to execute some perl code in the parent process, a moment
before a first child starts or any time after that?

The idea is to fork a monitor process (you cannot run it from shell, since
you will be unable to Access the server's object) and have it poll
children every X seconds, and if there is some process that runs longer
than Y seconds we kill it.

Another question regarding the last sentence. Let's say I've got a PID of
the process that hangs, is it enough to send kill('SIGPIPE',$pid) to
terminate the request or should I always kill('SIGINT',$pid) to kill the
process?

The third question is again regarding the main process. If I fork the
process during a startup, when I perform 'apachectl stop' all the
processes die but the one I've forked. Is there any way to install END{}
block in the parent main process, so the children wouldn't inherit it?
Otherwise if they do and it supposed to kill the forked process, a first
child that quits will kill off the monitor. (I could probably test the pid
of the process that executes the END block, since I know the pid of the
parent, I could execute the block only if it's parent process...)

Any ideas?

Thanks!

_______________________________________________________________________
Stas Bekman  mailto:[EMAIL PROTECTED]    www.singlesheaven.com/stas  
Perl,CGI,Apache,Linux,Web,Java,PC at  www.singlesheaven.com/stas/TULARC
www.apache.org  & www.perl.com  == www.modperl.com  ||  perl.apache.org
single o-> + single o-+ = singlesheaven    http://www.singlesheaven.com

Reply via email to