Re: mod_fcgi/perl: Problem with signals

Albert Leidinger <albert.leidinger-kt1KeoM4Q/BvMmomy+XrYrNldLUNz+W/@public.gmane.org>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <[email protected]>
Hi Marc!

The signal handling is done, as I wrote in another entry. I now receive 
the signals and the processes are terminated.
(It was result of the strict signal handling in new Perl-Versions)

But there is a problem with deallocation of the shared memory!

>
> sub sig_handler {
>     $exit_requested = 1;
> }
>
> while ($handling_request = ($request->Accept() >= 0)) {
>    &do_request;
>    $handling_request = 0;
>    last if $exit_requested;
> }
>
> warn "exiting";
> &dealloc_shared_memory;

Thanks for this peace of code. Yes, thats the only way its supposed to 
work, when the deallocation cant be done in the handler.
 But it doesnt. Here is my test script:

#!/usr/bin/perl

use FCGI;
use strict;

my $count = 0;
my $handling_request = 0;
my $exit_requested = 0;

my $request = FCGI::Request();

sub sig_handler {
    $exit_requested = 1;

    warn "got signal $_[0]";
}

$SIG{USR1} = \&sig_handler;
$SIG{TERM} = \&sig_handler;
$SIG{PIPE} = 'IGNORE';

while ($handling_request = ($request->Accept() >= 0)) {
    &do_request;
    $handling_request = 0;
    last if $exit_requested;
}

warn "exiting normal\n";
exit(0);

sub do_request() {
    print("Content-type: text/html\r\n\r\n", ++$count);
    $request->Finish();
}


When stopping Apache I get the "got signal TERM" but I dont get the 
"exiting normal"!

It seems the perl script is just terminated at the start of the loop.

Shouldnt FCGI::Accept return -1 when Apache is stopped, so that the code 
after the loop is beeing processed?
What can be wrong?
A bug? Again some incompatibility?

Thanks for every piece of information!

Albert
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.