+
+ status = write_archive_buffer ();
+ if (status != record_size)
+ archive_write_error (status);
+ }
+
+#if 0
+ close_archive ();
+#endif
+
+ /* Propagate any failure of the grandchild back to the parent. */
+
+ while (waitpid (grandchild_pid, &wait_status, 0) == -1)
+ if (errno != EINTR)
+ {
+ waitpid_error (use_compress_program_option);
+ break;
+ }
+
+ if (WIFSIGNALED (wait_status))
+ {
+ kill (child_pid, WTERMSIG (wait_status));
+ exit_status = TAREXIT_FAILURE;
+ }
+ else if (WEXITSTATUS (wait_status) != 0)
+ exit_status = WEXITSTATUS (wait_status);
+
+ exit (exit_status);
+}
+
+/* Set ARCHIVE for uncompressing, then reading an archive. */
+static void
+child_open_for_uncompress (void)
+{
+ int parent_pipe[2];
+ int child_pipe[2];
+ pid_t grandchild_pid;
+ int wait_status;
+
+ xpipe (parent_pipe);
+ child_pid = xfork ();
+
+ if (child_pid > 0)
+ {
+ /* The parent tar is still here! Just clean up. */
+
+ read_full_records_option = 1;
+ archive = parent_pipe[PREAD];
+ xclose (parent_pipe[PWRITE]);
+ return;
+ }
+
+ /* The newborn child tar is here! */
+
+ program_name = _("tar (child)");
+
+ xdup2 (parent_pipe[PWRITE], STDOUT_FILENO);
+ xclose (parent_pipe[PREAD]);
+
+ /* Check if we need a grandchild tar. This happens only if either:
+ a) we're reading stdin: to force unblocking;
+ b) the file is to be accessed by rmt: compressor doesn't know how;
+ c) the file is not a plain file. */
+
+ if (strcmp (archive_name_array[0], "-") != 0
+ && !_remdev (archive_name_array[0])
+ && is_regular_file (archive_name_array[0]))
+ {
+ /* We don't need a grandchild tar. Open the archive and lauch the
+ uncompressor. */
+
+ archive = open (archive_name_array[0], O_RDONLY | O_BINARY, MODE_RW);
+ if (archive < 0)
+ open_fatal (archive_name_array[0]);
+ xdup2 (archive, STDIN_FILENO);
+ execlp (use_compress_program_option, use_compress_program_option,
+ "-d", (char *) 0);
+ exec_fatal (use_compress_program_option);