Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

SIGPIPE not trapped after sleep in CGI

by GwenDragon (Novice)
on Oct 28, 2012 at 11:35 UTC ( #1001264=perlquestion: print w/ replies, xml ) Need Help??
GwenDragon has asked for the wisdom of the Perl Monks concerning the following question:

Please, I'd like to know, why SIPIPE is not trapped after aborting a CGI connection and using sleep()?

Testcase:

1. Uploaded CGI to webserver

2. fetched it with browser

3. After 5-10 seconds hit abort button in browser

4. Inspect debug.txt

5. Only END output is in debug file.

#!/usr/bin/perl $SIG{PIPE} = sub { open my $fh, '>>', 'debug.txt'; print $fh "Debug: died PIPE.\n"; close $fh; CORE::die "Pipe: @_\n"; }; $| = 1; use strict; use warnings; use CGI (); my $q = CGI->new(); print $q->header(); print "output #1\n"; warn "Debug: RUNNING"; sleep 30; print "output #2\n"; END { open my $fh, '>>', 'debug.txt'; print $fh "Debug: END block.\n"; close $fh; }

Then i thought, using pragma traphandler would help so solve the prob. I tried use sigtrap 'handler' => \&my_handler, 'normal-signals'; to trap SIGPIPE, without any effort.

After removing sleep in my testcase the trapping of SIGPIPE by my signal handler works fine.

Why does sleep disable signal trapping and the installed signal handler? Can yo explain this ti me?

Comment on SIGPIPE not trapped after sleep in CGI
Select or Download Code
Re: SIGPIPE not trapped after sleep in CGI
by zwon (Monsignor) on Oct 28, 2012 at 13:37 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1001264]
Approved by McDarren
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2014-09-15 02:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (145 votes), past polls