Tar process not dying after user hits "stop"

[prev] [thread] [next] [Date index for 2004/12/12]

From: Mike Cardwell
Subject: Tar process not dying after user hits "stop"
Date: 16:11 on 12 Dec 2004
Hi people,

I'm using:

Apache/1.3.33
mod_perl/1.29

On a Debian Sarge system.

The code I'm having problems with is quite long, so I've written a cut 
down version. In my virtual host block I have something along the lines 
of:

<Location /test.tar>
       SetHandler perl-script
       PerlHandler My::Handler
</Location>

Basically, you go to /test.tar and a tarball is returned by My::Handler. 
However, it is generated on the fly like:

# Get the content-length:
my( $command ) = "/bin/tar -c -h -f /dev/null --totals the_directory 2>&1"=~/^(.+)$/;
`$command` =~ /Total bytes written: (\d+)/gsm;

# Send the content-length
$r->header_out('Content-Length', $1 );

# Open a "filehandle" to the tar command
( $command ) = "/bin/tar -c -h -f - the_directory 2>/dev/null"=~/^(.+)$/;
open my $filehandle,"$command |";

# Send the data:
$r->send_fd( $filehandle );

# Close the filehandle
close $filehandle;

The problem is, when someone hits stop in their web browser and ends the 
transfer prematurely, the tar command doesn't die like I'd hoped it would. 
I'm assuming here that I'm missing something basic in my knowledge of how 
modperl works...

Thank you in advance for any help.

P.S. I included the content-length part just in case anyone knew of a 
better way to calculate the size a tarball is going to be before it is 
actually generated...

        -- 
        Digital photo printing and photos onto gifts:
http://www.fotoserve.com/?affiliate_id=1093871459

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Tar process not dying after user hits "stop"
Mike Cardwell 16:11 on 12 Dec 2004

Re: Tar process not dying after user hits "stop"
Mike Cardwell 00:57 on 13 Dec 2004

Re: Tar process not dying after user hits "stop"
Steven Lembark 06:11 on 13 Dec 2004

Generated at 11:26 on 21 Dec 2004 by mariachi v0.52