You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Heiko Marschall <hm...@garmisch.net> on 1998/05/17 13:12:05 UTC

mod_cgi/2240: CGI killed 3 seconds after loosing client

>Number:         2240
>Category:       mod_cgi
>Synopsis:       CGI killed 3 seconds after loosing client
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          support
>Submitter-Id:   apache
>Arrival-Date:   Sun May 17 04:20:00 PDT 1998
>Last-Modified:
>Originator:     hm@garmisch.net
>Organization:
apache
>Release:        1.3b6
>Environment:
linux 2.0.32 
>Description:
When loosing connection to the browser, my cgi-script gets a TERM-signal.
But when I go on executing the script (e.g. by $SIG{TERM}=SIG_IGN) the script
aborts after about 3 seconds. But I receive no more signal (maybe an KILL ?) to
handle with.
This behavior is independent from writing to the browser, even writing to disk
after receiving the TERM-signal doesn�t help.
As you see in my example i tried to catch all the known signals.
Only KILL cannot be snatched. So i think Apache sends me an KILL signal ?
>How-To-Repeat:
#!/usr/bin/perl

use Config;


@sigs=(
ZERO,HUP,INT,QUIT,ILL,ABRT,TRAP,IOT,BUS,FPE,KILL,USR1,SEGV,USR2,PIPE,ALRM,TERM,CHLD,
CONT,STOP,TSTP,TTIN,TTOU,URG,XCPU,XFSZ,VTALRM,PROF,WINCH,IO,PWR,STKFLT,UNUSED,IOT,CLD,
POLL);
        
sub handler
        {
        local ($sig) = @_;
        
        open STDOUT,">afterterm.txt";
        for ($i=1; $i < 20; $i++)
                {
                print STDOUT "test $i\n";
                sleep(1);
                }
# breaks after 3 seconds !!!
        close STDOUT;
        exit(0);
        }

foreach (@sigs)
        {
        $SIG{$_}=\&handler;
        }

$SIG{SEGV}=SIG_IGN;
$SIG{PIPE}=SIG_IGN;
$SIG{TERM}=\&handler;

$|=1;

open SIG, ">sig.test";
select SIG; $|=1;
select STDOUT;

print "Content-type: text/html\n\n";
print "<html><body>\n";
for ($i=0; $i< 20; $i++)
        {
        print "zahl:$i<br>\n";  # writing to browser
        print SIG "zahl:$i<br>\n";  # writing to disk
        sleep (1);
        }
close SIG;
>Fix:

>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, ]
[you need to include <ap...@Apache.Org> in the Cc line ]
[and leave the subject line UNCHANGED.  This is not done]
[automatically because of the potential for mail loops. ]