* src/tar.c (main): Ignore SIGPIPE.
* src/system.c (sys_child_open_for_compress)
(sys_child_open_for_uncompress): Reset SIGPIPE
in child to default.
* tests/remfiles01.at: Avoid race conditions.
* tests/remfiles02.at: Likewise.
/* The new born child tar is here! */
set_program_name (_("tar (child)"));
-
+ signal (SIGPIPE, SIG_DFL);
+
xdup2 (parent_pipe[PREAD], STDIN_FILENO);
xclose (parent_pipe[PWRITE]);
/* The newborn child tar is here! */
set_program_name (_("tar (child)"));
-
+ signal (SIGPIPE, SIG_DFL);
+
xdup2 (parent_pipe[PWRITE], STDOUT_FILENO);
xclose (parent_pipe[PREAD]);
obstack_init (&argv_stk);
/* Ensure default behavior for some signals */
- signal (SIGPIPE, SIG_DFL);
+ signal (SIGPIPE, SIG_IGN);
/* System V fork+wait does not work if SIGCHLD is ignored. */
signal (SIGCHLD, SIG_DFL);
genfile --file b
mkdir c
-tar -c -f a -z --remove-files b c
+# Depending on when the SIGPIPE gets delivered, the invocation below
+# may finish with either
+# tar: a: Cannot write: Broken pipe
+# or
+# tar: Child returned status 2
+tar -c -f a -z --remove-files b c 2>err
+EC=$?
+sed -n '/(child)/p' err >&2
+rm err
find . | sort
+exit $EC
],
-[0],
+[2],
[.
./a
./b
genfile --file b
mkdir c
-tar -c -f a -z --remove-files b c
-
+tar -c -f a -z --remove-files b c 2>err
+EC=$?
+sed -n '/(child)/p' err >&2
+rm err
find . | sort
+exit $EC
],
-[0],
+[2],
[.
./a
./b
],
[tar (child): a: Cannot open: Is a directory
tar (child): Error is not recoverable: exiting now
-tar: Child returned status 2
-tar: Error is not recoverable: exiting now
])
AT_CLEANUP