Hi,

Stas Bekman wrote:

> Apache 1.3.6 and up -- STOP pressed:
>
> the code keeps on running until it tries to read from or write to the
> socket. the moment this happens, the script will stop the execution, and
> run cleanup phase.
>
> I think it's the same under mod_perl and mod_cgi. Am I right?

I have a script which I wish to run under either mod_perl or CGI which does
little more than display content and I would like it to stop when the user
presses Stop, but I can't get it working.

I've been trying to figure things out with the following test program:

---
use strict;
use warnings;
$SIG{PIPE} = \&handler;
$| = 1;
print "Content-Type: text/plain\n\n";
for (;;) {
    for (1 .. 1000000) { ; }
    print "x\n";
}
sub handler {
    # Unreliable signals on NT:-
    $SIG{PIPE} = \&handler;
    exit;
}
---

(The pointless time-wasting loop just before each print() is so that I can
easily see whether the program actually has exited or not -- I'm running on NT
(groan!) and I can see in my "Task Manager" display that the Apache child
process is flat out 100% CPU while its running.)

I would expect that when the user presses Stop and the script next tries a
print() it'll get a SIGPIPE, call the handler(), and exit().

But it doesn't -- the Apache child process just carries on at 100% CPU.

It makes no difference whether I run it under mod_perl or mod_cgi (except that,
of course, I get a Perl process at 100% CPU instead of the Apache child), and it
also makes no difference if I take out the first "$SIG{PIPE} = \&handler;" line
(and rely on mod_perl to handle the SIGPIPE for me as Stas described above)
and/or put the "PerlFixupHandler Apache::SIG" directive in my httpd.conf.

Can anybody help/explain?

I'm running Apache/1.3.17 and mod_perl/1.25 on Windows NT 4.

Cheers,
Steve Hay


Reply via email to