diff options
author | kientzle <kientzle@FreeBSD.org> | 2008-06-15 10:45:57 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2008-06-15 10:45:57 +0000 |
commit | fc70e49ebfd776d40b338afe8257f404b59449e0 (patch) | |
tree | 9a91ef4fcb23000923100d4ae69479ce72a92b2a /lib/libarchive/archive_write_set_compression_program.c | |
parent | bfa1b1945861a658152087251d6468ed8a8fd201 (diff) | |
download | FreeBSD-src-fc70e49ebfd776d40b338afe8257f404b59449e0.zip FreeBSD-src-fc70e49ebfd776d40b338afe8257f404b59449e0.tar.gz |
A number of minor corrections to the support for external compression
programs:
* Support platforms that have fork() but not vfork()
* Don't write(), select(), or poll() against closed file descriptors
Diffstat (limited to 'lib/libarchive/archive_write_set_compression_program.c')
-rw-r--r-- | lib/libarchive/archive_write_set_compression_program.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libarchive/archive_write_set_compression_program.c b/lib/libarchive/archive_write_set_compression_program.c index b910ef6..3cd5c93 100644 --- a/lib/libarchive/archive_write_set_compression_program.c +++ b/lib/libarchive/archive_write_set_compression_program.c @@ -28,7 +28,9 @@ __FBSDID("$FreeBSD$"); /* This capability is only available on POSIX systems. */ -#if !defined(HAVE_PIPE) || !defined(HAVE_VFORK) || !defined(HAVE_FCNTL) +#if !defined(HAVE_PIPE) || !defined(HAVE_FCNTL) || \ + !(defined(HAVE_FORK) || defined(HAVE_VFORK)) +#include "archive.h" /* * On non-Posix systems, allow the program to build, but choke if @@ -180,6 +182,12 @@ restart_write: if (ret == -1 && errno != EAGAIN) return (-1); + if (state->child_stdout == -1) { + fcntl(state->child_stdin, F_SETFL, 0); + __archive_check_child(state->child_stdin, state->child_stdout); + goto restart_write; + } + do { ret = read(state->child_stdout, state->child_buf + state->child_buf_avail, |