Leser: 22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/perl $| = 1; $SIG{PIPE} = sub { die "Pipe: @_\n"; }; use strict; use warnings; use CGI (); my $q = CGI->new(); print $q->header(); print "output #1\n"; warn "Debug: RUNNING"; sleep 20; print "output #2\n"; END { open my $fh, '>>', 'debug.txt'; print $fh "Debug: END block.\n"; close $fh; }
Quotehttp://modperlbook.org/html/6-9-Handling-the-User-...Prior to Apache 1.3.6, SIGPIPE was handled by Apache. Currently, Apache does not handle SIGPIPE, but mod_perl takes care of it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#!/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; }
$ENV{PERL_SIGNALS} = "unsafe";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#!/usr/bin/perl $|++; use strict; use warnings; use CGI::Fast; $SIG{PIPE} = sub { open my $fh, '>>', 'debug.txt'; print $fh "Debug: " . scalar localtime . " died PIPE.\n"; close $fh; CORE::die "Pipe: @_\n"; }; while ( my $q = new CGI::Fast ) { print $q->header('text/plain'); print "output #1\n"; warn "Debug: RUNNING"; foreach my $nr(1..10000000){ print "test text $nr\n"; } print "output #2\n"; last if ( -M $ENV{'SCRIPT_FILENAME'} < 0 ); } END { open my $fh, '>>', 'debug.txt'; print $fh "Debug: END block.\n"; close $fh; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#!/usr/bin/perl $|++; use strict; use warnings; use CGI; $SIG{PIPE} = sub { open my $fh, '>>', 'debug_cgi.txt'; print $fh "Debug: " . scalar localtime . " died PIPE.\n"; close $fh; CORE::die "Pipe: @_\n"; }; my $q = new CGI; print $q->header('text/plain'); print "output #1\n"; warn "Debug: RUNNING"; foreach my $nr ( 1 .. 10000000 ) { print "test text $nr\n"; } print "output #2\n"; END { open my $fh, '>>', 'debug_cgi.txt'; print $fh "Debug: END block.\n"; close $fh; }
die('hard') unless( print "alive?" );
2012-10-27T14:08:33 kristianes geht wohl auch sehr an der eigentlichen situation vorbei, ich kenne diese auch nicht.