D
Dave Saville
Due to lots of reasons I won't go into here I need a cgi-script to
push out video files. I knocked up a quick and dirty test that works
but if I kill the viewer the perl instance seems to hang around
forever. Although it is killable. It did occur to me that Apache might
kill it eventually when he sees the connection is not requesting
anymore data but it seems not.
So it the interests of being tidy I want to terminate if I have not
sent anything for X.
#!d:/usr/bin/perl5.16.0.exe
use strict;
use warnings;
print "Content-type: text/plain\n\n";
open my $STREAM, '<', "t:/tmp/Foo.rec" or die $!;
binmode $STREAM;
binmode STDOUT;
my $rc = 1;
while ( $rc )
{
$rc = read $STREAM, my $buffer, 4096;
die $! if undef $rc;
eval
{
local $SIG{ALRM} = sub{die "too long" };
alarm 60;
print $buffer;
alarm 0;
};
exit if $@ =~ m{^too long};
}
But it never terminates. Any ideas? I realise that both perl and
apache and the "system" are probably buffering away but whatever, I
would have though my script would wait in the print?
push out video files. I knocked up a quick and dirty test that works
but if I kill the viewer the perl instance seems to hang around
forever. Although it is killable. It did occur to me that Apache might
kill it eventually when he sees the connection is not requesting
anymore data but it seems not.
So it the interests of being tidy I want to terminate if I have not
sent anything for X.
#!d:/usr/bin/perl5.16.0.exe
use strict;
use warnings;
print "Content-type: text/plain\n\n";
open my $STREAM, '<', "t:/tmp/Foo.rec" or die $!;
binmode $STREAM;
binmode STDOUT;
my $rc = 1;
while ( $rc )
{
$rc = read $STREAM, my $buffer, 4096;
die $! if undef $rc;
eval
{
local $SIG{ALRM} = sub{die "too long" };
alarm 60;
print $buffer;
alarm 0;
};
exit if $@ =~ m{^too long};
}
But it never terminates. Any ideas? I realise that both perl and
apache and the "system" are probably buffering away but whatever, I
would have though my script would wait in the print?