modperl_sig_overriding

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



To: Jeremy Rusnak <jrusnak@igl.net>
From: Stas Bekman <stas@stason.org>
Subject: Re: UPDATE: Hanging processes (all of a sudden!)
Date: Wed, 21 Feb 2001 14:07:15 +0800 (SGT)

On Tue, 20 Feb 2001, Jeremy Rusnak wrote:

> Hello all,
>
> Just to followup on myself...I did some more experiments and determined
> that putting the alarm routines in a library wasn't really working right.
> It would work correctly on the first request per child but after that
> failed.  I ended up with:
>
> # failsafe to prevent broken children
> $SIG{ALRM} = sub { die "$0: $$ Process Timed Out" };
> $SIG{PIPE} = sub { die "$0: $$ Cancelled via SIGPIPE" };
> $SIG{TERM} = sub { die "$0: $$ Cancelled via SIGTERM" };
> alarm 10;

That's how SIG overriding works. After the first time a sig is caught --
the handler gets reset to a DEFAULT. What you need to do is to re-assign
the handler at the end of the handler itself:

$SIG{TERM} = &handler;
sub handler{ die "$0: $$ Process Timed Out"; $SIG{TERM} = &handler; }

> This is at the beginning of all my scripts using mod_perl.   I'm tweaking
> the timeout.  Without using the alarm signal things still get nasty,
> though.
>
> Load on the box is back down to 1...However the timeout issue is a little
> nasty.  Users on slow connects are getting timed out rather than the
> script finishing.  I'm trying to determine where the hangs are happening
> so I can reset the alarm timer in the script.

Also check out the Apache::Watchdog::RunAway app.

> I still can't quite figure out why they are hanging in the first place,
> I know it has to do with the clients disconnecting from the script
> but I assumed that SIGPIPE would catch them.  It isn't doing that in
> all cases, I guess it depends where the disconnect occurs in the
> script.

The guide has at least two section about catching these:
http://perl.apache.org/guide/debug.html#Handling_the_User_pressed_Stop_
http://perl.apache.org/guide/debug.html#Hanging_Processes_Detection_and


> I hope this is helpful to others, but I still am looking for more
> answers to this!


===


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu