diff options
author | H. Peter Anvin <hpa@zytor.com> | 2011-09-26 15:39:03 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2011-09-26 15:39:03 -0700 |
commit | 103e1d0e17a0ba7f0b8b4e01f3a0decb275fc19d (patch) | |
tree | 25618397cc780e19af76adb3b243d167b775f5ee | |
parent | fda5008826f09a54f42d6078c69708cdbe24ec2a (diff) | |
download | kup-103e1d0e17a0ba7f0b8b4e01f3a0decb275fc19d.tar.gz |
Don't go through the shell for the compression processes
-rw-r--r-- | data-upload.pl | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/data-upload.pl b/data-upload.pl index 0579238..9dd0ec8 100644 --- a/data-upload.pl +++ b/data-upload.pl @@ -199,13 +199,17 @@ sub make_compressed_data() die if (!$have_data); my %workers; - my @jobs = - ("/bin/gzip -9 < \Q${tmpdir}/data\E > \Q${tmpdir}/data.gz\E", - "/usr/bin/bzip2 -9 < \Q${tmpdir}/data\E > \Q${tmpdir}/data.bz2\E", - "/usr/bin/xz -9 < \Q${tmpdir}/data\E > \Q${tmpdir}/data.xz\E"); + my @cmds = (['/bin/gzip', '-9'], + ['/usr/bin/bzip2', '-9'], + ['/usr/bin/xz', '-9']); + my @exts = ('.gz', '.bz2', '.xz'); my $nworkers = 0; + my $i, @c, $e; + + for ($i = 0; $i < scalar @cmds; $i++) { + my @c = @{$cmds[$i]}; + my $e = $exts[$i]; - foreach my $j (@jobs) { my $w = fork(); if (!defined($w)) { @@ -213,7 +217,15 @@ sub make_compressed_data() } if ($w == 0) { - exec($j); + sysopen(RAW, $tmpdir.'/data', O_RDONLY) + or exit 127; + sysopen(OUT, $tmpdir.'/data'.$e, O_WRONLY, 0002) + or exit 127; + + open(STDIN, '<&', \*RAW) or exit 127; + open(STDOUT, '>&', \*OUT) or exit 127; + + exec(@c); exit 127; } |