You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Bill Moseley <mo...@hank.org> on 2000/02/24 02:47:15 UTC

speaking of $SIG{__DIE__}

Apache::RegistryNG script:  mod_perl-1.21 Apache 1.3.11 Solaris 2.6 perl
5.00503

I though this a bit interesting:

I use a $SIG{__DIE__} handler that prints a nice message and then calls exit.

One thing I noticed that if I use CGI.pm to write that nice message that
the Apache child dies after calling exit.  If I just use print() (with
PerlSendHeader on) it works fine and the Apache child lives on to serve
another request.

Seems to do the same thing with $SIG{__WARN__}.

This is error_log
panic: POPSTACK
Callback called exit.

#!/usr/local/bin/perl5.00503 -wT
use strict;

use CGI;
use Apache;

$SIG{__DIE__} =
    sub {
        print CGI::header(),
#        print "Content-type: text/plain\n\n",        
        "Child $$\n";
        Apache->exit;
    };

die;


Bill Moseley
mailto:moseley@hank.org

RE: speaking of $SIG{__DIE__}

Posted by Chris Nokleberg <ch...@sportsrocket.com>.
I've run into this exit-in-SIGDIE-POPSTACK problem before, and wasn't using
CGI.pm. It is a bug in Perl that I believe has been fixed in the
development versions.

It is not guaranteed to happen, and I managed to get it to work without
errors eventually, but it required changing a lot of my error handling
code; you'll probably have to mess with the internals of CGI.pm.

Chris

> -----Original Message-----
> From: Bill Moseley [mailto:moseley@hank.org]
> Sent: Wednesday, March 01, 2000 8:05 AM
> To: Doug MacEachern
> Cc: modperl@apache.org
> Subject: Re: speaking of $SIG{__DIE__}
>
>
> At 11:28 PM 02/29/00 -0800, Doug MacEachern wrote:
> >On Wed, 23 Feb 2000, Bill Moseley wrote:
> >
> >> Apache::RegistryNG script:  mod_perl-1.21 Apache 1.3.11
> Solaris 2.6 perl
> >> 5.00503
> >>
> >> I though this a bit interesting:
> >>
> >> I use a $SIG{__DIE__} handler that prints a nice message and
> then calls
> exit.
> >>
> >> One thing I noticed that if I use CGI.pm to write that nice
> message that
> >> the Apache child dies after calling exit.  If I just use print() (with
> >> PerlSendHeader on) it works fine and the Apache child lives
> on to serve
> >> another request.
> >>
> >> Seems to do the same thing with $SIG{__WARN__}.
> >>
> >> This is error_log
> >> panic: POPSTACK
> >> Callback called exit.
> >>
> >> #!/usr/local/bin/perl5.00503 -wT
> >> use strict;
> >>
> >> use CGI;
> >> use Apache;
> >>
> >> $SIG{__DIE__} =
> >>     sub {
> >>         print CGI::header(),
> >> #        print "Content-type: text/plain\n\n",
> >>         "Child $$\n";
> >>         Apache->exit;
> >
> >why do you call Apache->exit here?  try removing it.
>
> It should be ok to exit in a __DIE__ handler.  That's what perlvar says.
>
> If you don't call exit() then Apache generates its own error
> message, which
> is what I'm trying to override.  I think this is more  CGI.pm issue.



Re: speaking of $SIG{__DIE__}

Posted by Doug MacEachern <do...@pobox.com>.
On Wed, 1 Mar 2000, Bill Moseley wrote:

> It should be ok to exit in a __DIE__ handler.  That's what perlvar says.

there is a big difference between CORE::exit and Apache::exit, perlvar is
not refering to Apache::exit :)
but your handler works fine for me with 5.005_03 and 5.005_67 anyhow.

> If you don't call exit() then Apache generates its own error message, which
> is what I'm trying to override.  I think this is more  CGI.pm issue.

maybe custom_response will help you:

my $r = shift;

$r->custom_response(500, "Child $$\n");

die "whoops";



Re: speaking of $SIG{__DIE__}

Posted by Bill Moseley <mo...@hank.org>.
At 11:28 PM 02/29/00 -0800, Doug MacEachern wrote:
>On Wed, 23 Feb 2000, Bill Moseley wrote:
>
>> Apache::RegistryNG script:  mod_perl-1.21 Apache 1.3.11 Solaris 2.6 perl
>> 5.00503
>> 
>> I though this a bit interesting:
>> 
>> I use a $SIG{__DIE__} handler that prints a nice message and then calls
exit.
>> 
>> One thing I noticed that if I use CGI.pm to write that nice message that
>> the Apache child dies after calling exit.  If I just use print() (with
>> PerlSendHeader on) it works fine and the Apache child lives on to serve
>> another request.
>> 
>> Seems to do the same thing with $SIG{__WARN__}.
>> 
>> This is error_log
>> panic: POPSTACK
>> Callback called exit.
>> 
>> #!/usr/local/bin/perl5.00503 -wT
>> use strict;
>> 
>> use CGI;
>> use Apache;
>> 
>> $SIG{__DIE__} =
>>     sub {
>>         print CGI::header(),
>> #        print "Content-type: text/plain\n\n",        
>>         "Child $$\n";
>>         Apache->exit;
>
>why do you call Apache->exit here?  try removing it.

It should be ok to exit in a __DIE__ handler.  That's what perlvar says.

If you don't call exit() then Apache generates its own error message, which
is what I'm trying to override.  I think this is more  CGI.pm issue.


Bill Moseley
mailto:moseley@hank.org

Re: speaking of $SIG{__DIE__}

Posted by Doug MacEachern <do...@pobox.com>.
On Wed, 23 Feb 2000, Bill Moseley wrote:

> Apache::RegistryNG script:  mod_perl-1.21 Apache 1.3.11 Solaris 2.6 perl
> 5.00503
> 
> I though this a bit interesting:
> 
> I use a $SIG{__DIE__} handler that prints a nice message and then calls exit.
> 
> One thing I noticed that if I use CGI.pm to write that nice message that
> the Apache child dies after calling exit.  If I just use print() (with
> PerlSendHeader on) it works fine and the Apache child lives on to serve
> another request.
> 
> Seems to do the same thing with $SIG{__WARN__}.
> 
> This is error_log
> panic: POPSTACK
> Callback called exit.
> 
> #!/usr/local/bin/perl5.00503 -wT
> use strict;
> 
> use CGI;
> use Apache;
> 
> $SIG{__DIE__} =
>     sub {
>         print CGI::header(),
> #        print "Content-type: text/plain\n\n",        
>         "Child $$\n";
>         Apache->exit;

why do you call Apache->exit here?  try removing it.

>     };
> 
> die;
> 
> 
> Bill Moseley
> mailto:moseley@hank.org
>