* Use IO::Handles instead of old school filehandles. This ensures

that the pipe gets closed, and the child process dies, if the HTTP
  connection is prematurely interrupted.
This commit is contained in:
Eelco Dolstra 2009-03-11 14:44:34 +00:00
parent 7ea69e7a9d
commit 8b752627a2
3 changed files with 6 additions and 11 deletions

View file

@ -11,10 +11,9 @@ sub process {
my @storePaths = @{$c->stash->{storePaths}};
open(OUTPUT, "nix-store --export `nix-store -qR @storePaths` | gzip |");
my $fh = new IO::Handle;
$fh->fdopen(fileno(OUTPUT), "r") or die;
open $fh, "nix-store --export `nix-store -qR @storePaths` | gzip |";
$c->response->body($fh);

View file

@ -11,10 +11,9 @@ sub process {
my @storePaths = @{$c->stash->{storePaths}};
open(OUTPUT, "nix-store --query --graph @storePaths | dot -Tpng -Gbgcolor=transparent |");
my $fh = new IO::Handle;
$fh->fdopen(fileno(OUTPUT), "r") or die;
open $fh, "nix-store --query --graph @storePaths | dot -Tpng -Gbgcolor=transparent |";
$c->response->body($fh);

View file

@ -10,15 +10,12 @@ sub process {
$c->response->content_type('application/x-nix-archive'); # !!! check MIME type
open(OUTPUT, "nix-store --dump '$storePath' | bzip2 |");
my $fh = new IO::Handle;
$fh->fdopen(fileno(OUTPUT), "r") or die;
open $fh, "nix-store --dump '$storePath' | bzip2 |";
$c->response->body($fh);
undef $fh;
return 1;
}