> The reason why the stop button does not stop the script lies in the fact
> that you're script does not produce any output while it is running. SIGPIPE
> is only raised when your script tries to write to a closed (STOPed)
> connection. No output from your script = no SIGPIPE!

That's right, Tobias.

I've checked the Apache::SIG and $r->connection->aborted, but is there a
way to "write" without actually writing, probably some control char will
do? Something like:

  while(1){
    $r->print("\0");
    last if $r->connection->aborted;
    $i++;
    sleep (1);
  }

I guess you must flush it as well, otherwise it would be cached... so
either $|++ or $r->rflush, this one seems to work:

  while(1){
    $r->print("\0");
    $r->rflush;
    last if $r->connection->aborted;
    $i++;
    sleep (1);
  }

but this one doesn't work (removed "last if $r->connection->aborted").
Which seems that makes mod_perl broken

  while(1){
    $r->print("$$\n");
    $r->rflush;
    $i++;
    sleep (1);
  }

See the output of strace, when I press Stop - it detects the SIGPIPE but
doesn't quit!

[snip]
nanosleep(0xbffff308, 0xbffff308, 0x401a61b4, 0xbffff308, 0xbffff41c) = 0
time([940621341])                       = 940621341
write(4, "22572\n", 6)                  = -1 EPIPE (Broken pipe)
--- SIGPIPE (Broken pipe) ---
time([940621341])                       = 940621341
SYS_175(0, 0xbffff41c, 0xbffff39c, 0x8, 0) = 0
SYS_174(0x11, 0, 0xbffff1a0, 0x8, 0x11) = 0
SYS_175(0x2, 0xbffff39c, 0, 0x8, 0x2)   = 0
nanosleep(0xbffff308, 0xbffff308, 0x401a61b4, 0xbffff308, 0xbffff41c) = 0
[snip]
continues non-stop here

So Apache::SIG doesn't set correctly the mod_perl's default behaviour,
since when I add: 

        use Apache::SIG ();
        Apache::SIG->set;

It stops right away after I press the Stop button.

I run Apache/1.3.10-dev mod_perl/1.22-dev (CVS snapshot a few days old)



> 
> Tobias
> 
> At 07:29 PM 10/22/99 +0200, Stas Bekman wrote:
> >Hi,
> >
> >Let's take a little script that obviously "hangs" the server:
> >
> >  my $r = shift;
> >  $r->send_http_header('text/plain'); 
> >  $|=1; # so we would see the $$ printed
> >  print "OK $$\n";
> >  sleep 1, $i++ while 1;
> >
> >The second question is how comes that the above little script never quits
> >after the stop button was pressed? Apache was supposed to detect SIGPIPE
> >and abort the run... but it doesn't - it's very easy to reproduce - just
> >run it... I've used $|=1 to print the $$ and check that it really hangs...
> >
> >Thanks!
> >
> >_______________________________________________________________________
> >Stas Bekman  mailto:[EMAIL PROTECTED]    www.singlesheaven.com/stas  
> >Perl,CGI,Apache,Linux,Web,Java,PC at  www.singlesheaven.com/stas/TULARC
> >www.apache.org  & www.perl.com  == www.modperl.com  ||  perl.apache.org
> >single o-> + single o-+ = singlesheaven    http://www.singlesheaven.com
> >
> >
> 
> 
> 



_______________________________________________________________________
Stas Bekman  mailto:[EMAIL PROTECTED]    www.singlesheaven.com/stas  
Perl,CGI,Apache,Linux,Web,Java,PC at  www.singlesheaven.com/stas/TULARC
www.apache.org  & www.perl.com  == www.modperl.com  ||  perl.apache.org
single o-> + single o-+ = singlesheaven    http://www.singlesheaven.com

Reply via email to