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

I'm running Apache/mod_perl 2 under a Linux OS (forked MPM's) with Perl 5.8.7 compiled, where each Apache child has a number of threads, cond_waiting on a locked shared reference, haning out and waiting for cond_signals.

$threads::VERSION = 0.99; $threads::shared::VERSION = 0.90;


The issue I keep running into is my Apache children seem to randomly get shot by a SIGALRM.

Example:
[Mon Oct 23 16:01:07 2006] [notice] child pid exit signal Alarm clock + (14)


Without going to deep into the application it's self (it's too complex for this post), I should point out that I am using alarm()s in the app. Though, they are all being handled, all in a local context. Subsequently, if I take the threads out, I don't have this issue.

My question simply is (multi-part): I'm now trying to simply catch the SIGALRM in the child and sink it before it kills the child, however this is certainly something I don't want to do moving foward. Any thoughts?

---------
perl -le '$.=[qw(104 97 124 124 116 97)];*p=sub{[@{$_[0]},(45)x 2]};*d=sub{[(45)x 2,@{$_[0]}]};print map{chr}@{p(d($.))}'

Replies are listed 'Best First'.
Re: Random SIGALRM in mod_perl
by ysth (Canon) on Oct 24, 2006 at 09:02 UTC
    You can set a signal handler in C (via Inline) and maybe get more information on what is triggering the signal if you use sigaction's SA_SIGINFO flag and examine the siginfo_t that's passed to the signal handler. See http://www.opengroup.org/onlinepubs/000095399/basedefs/signal.h.html (free registration required) for details.

    (Beginning with perl5.8.9, you'll be able to do this in pure perl with POSIX::SigAction.)

Re: Random SIGALRM in mod_perl (reset)
by tye (Sage) on Oct 24, 2006 at 16:39 UTC

    That's rather vague, so here is a vague guess. Perhaps if you alarm(20) and then don't take 20 seconds to handle that web request, then some subsequent web request will get an unexpected SIGALRM. You should probably be sure to alarm(0) when you finish a request and you may want to alarm(0) when you start a new request.

    - tye        

Re: Random SIGALRM in mod_perl
by perrin (Chancellor) on Oct 24, 2006 at 16:33 UTC
    This is probably not mod_perl's fault, since it doesn't catch signals. It may have to do with threads, or it may be due to the "safe signals" in later versions of perl. You can read more on this in the perlipc man page.