diff --git a/src/buffer.c b/src/buffer.c
index 17c4753f..e32c628d 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1115,6 +1115,16 @@ close_archive (void)
bufmap_free (NULL);
}
+void
+write_fatal_details (char const *name, ssize_t status, size_t size)
+{
+ write_error_details (name, status, size);
+ if (rmtclose (archive) != 0)
+ close_error (*archive_name_cursor);
+ sys_wait_for_child (child_pid, false);
+ fatal_exit ();
+}
+
/* Called to initialize the global volume number. */
void
init_volume_number (void)
diff --git a/src/misc.c b/src/misc.c
index 4cbfa42d..d3bb0e42 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1113,13 +1113,6 @@ file_removed_diag (const char *name, bool top_level,
diagfn (name);
}
-void
-write_fatal_details (char const *name, ssize_t status, size_t size)
-{
- write_error_details (name, status, size);
- fatal_exit ();
-}
-
/* Fork, aborting if unsuccessful. */
pid_t
xfork (void)
diff --git a/src/system.c b/src/system.c
index 94142336..dc0b2b0b 100644
--- a/src/system.c
+++ b/src/system.c
@@ -330,6 +330,7 @@ sys_child_open_for_compress (void)
pid_t grandchild_pid;
pid_t child_pid;
+ signal (SIGPIPE, SIG_IGN);
xpipe (parent_pipe);
child_pid = xfork ();
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d9a52b3e..f1d12410 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -62,6 +62,7 @@ TESTSUITE_AT = \
backup01.at\
chtype.at\
comprec.at\
+ comperr.at\
delete01.at\
delete02.at\
delete03.at\
diff --git a/tests/comperr.at b/tests/comperr.at
new file mode 100644
index 00000000..4d3da19d
--- /dev/null
+++ b/tests/comperr.at
@@ -0,0 +1,39 @@
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
+# Test suite for GNU tar.
+# Copyright 2015 Free Software Foundation, Inc.
+#
+# GNU tar is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# GNU tar is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+AT_SETUP([compressor program failure])
+AT_KEYWORDS([compress comperr])
+
+# Description: If the --use-compress-program fails, then it is unsafe
+# to assume that the created archive is OK. Tar should fail with a
+# prominent error message.
+# Reported by: Ole Tange
+# References: ,
+# http://lists.gnu.org/archive/html/bug-tar/2015-03/msg00002.html
+
+AT_TAR_CHECK([
+tar --use-compress-program false -cf a.tar . 2>err
+rc=$?
+sed -n '$p' err
+exit $rc
+],
+[2],
+[tar: Error is not recoverable: exiting now
+])
+
+AT_CLEANUP
+
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 085011c6..a08dc771 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -383,6 +383,7 @@ m4_include([shortupd.at])
m4_include([truncate.at])
m4_include([grow.at])
m4_include([sigpipe.at])
+m4_include([comperr.at])
AT_BANNER([Removing files after archiving])
m4_include([remfiles01.at])