+ my $off = 0;
+ while ($r > 0) {
+ my $w = syswrite($in, $buf, $r, $off);
+ if (defined $w) {
+ $r -= $w;
+ $off += $w;
+ } else {
+ err($env, "error writing temporary file: $!");
+ return;
+ }
+ }
+ }
+ unless (defined(sysseek($in, 0, SEEK_SET))) {
+ err($env, "error seeking temporary file: $!");
+ return;