From fc70e49ebfd776d40b338afe8257f404b59449e0 Mon Sep 17 00:00:00 2001 From: kientzle Date: Sun, 15 Jun 2008 10:45:57 +0000 Subject: 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 --- lib/libarchive/archive_write_set_compression_program.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/libarchive/archive_write_set_compression_program.c') 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, -- cgit v1.1