summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read_support_compression_program.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libarchive/archive_read_support_compression_program.c')
-rw-r--r--lib/libarchive/archive_read_support_compression_program.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libarchive/archive_read_support_compression_program.c b/lib/libarchive/archive_read_support_compression_program.c
index 5f6cb46..5d92b90 100644
--- a/lib/libarchive/archive_read_support_compression_program.c
+++ b/lib/libarchive/archive_read_support_compression_program.c
@@ -28,7 +28,8 @@ __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))
/*
* On non-Posix systems, allow the program to build, but choke if
@@ -177,6 +178,12 @@ restart_read:
state->child_in_buf_avail = ret;
}
+ if (state->child_stdin == -1) {
+ fcntl(state->child_stdout, F_SETFL, 0);
+ __archive_check_child(state->child_stdin, state->child_stdout);
+ goto restart_read;
+ }
+
do {
ret = write(state->child_stdin, state->child_in_buf,
state->child_in_buf_avail);
@@ -191,7 +198,7 @@ restart_read:
goto restart_read;
} else if (ret == 0 || (ret == -1 && errno == EPIPE)) {
close(state->child_stdin);
- state->child_stdout = -1;
+ state->child_stdin = -1;
fcntl(state->child_stdout, F_SETFL, 0);
goto restart_read;
} else {
OpenPOWER on IntegriCloud