When piping output through a filter (for compression/encryption), we need
to keep the underlying file descriptor open so we can check the output file
size. Previously it was being closed too early so Tarfile::size_estimate
was failing.
pid_t pid;
int wrapped_fd = spawn_filter(fd, program, &pid);
- close(fd);
return new FileFilter(fd, wrapped_fd, pid);
}
if (pid == -1)
return 0;
+ // The raw file descriptor was held open to track the output file size, but
+ // is not needed any longer.
+ close(fd_raw);
+
int status;
if (waitpid(pid, &status, 0) < 0) {
fprintf(stderr, "Error waiting for filter process: %m\n");