[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] tar doesn't stop after extracting with occurrence paramete
From: |
Sergey Poznyakoff |
Subject: |
Re: [Bug-tar] tar doesn't stop after extracting with occurrence parameter |
Date: |
Tue, 25 Nov 2008 14:18:30 +0200 |
address@hidden ha escrit:
> "tar -xzp --occurrence=1 --ignore-failed-read -C 'target' -f 'tgz'
> 'file'
> >/dev/null 2>&1"
> It extracts the file after some seconds but doesn't stop. top shows a
> gzip process running. After some minutes gzip stops and tar ends.
It is a leftover from preious versions: tar tries to drain the input
pipe in order to avoid subprocess termination via SIGPIPE. Thanks for
reporting the bug. Please try the attached patch.
Regards,
Sergey
Index: src/buffer.c
===================================================================
RCS file: /cvsroot/tar/tar/src/buffer.c,v
retrieving revision 1.124
diff -p -u -r1.124 buffer.c
--- src/buffer.c 3 Nov 2008 19:15:52 -0000 1.124
+++ src/buffer.c 25 Nov 2008 12:14:39 -0000
@@ -848,8 +848,6 @@ close_archive (void)
flush_archive ();
}
- sys_drain_input_pipe ();
-
compute_duration ();
if (verify_option)
verify_volume ();
@@ -857,7 +855,7 @@ close_archive (void)
if (rmtclose (archive) != 0)
close_error (*archive_name_cursor);
- sys_wait_for_child (child_pid);
+ sys_wait_for_child (child_pid, hit_eof);
tar_stat_destroy (¤t_stat_info);
if (save_name)
Index: src/common.h
===================================================================
RCS file: /cvsroot/tar/tar/src/common.h,v
retrieving revision 1.107
diff -p -u -r1.107 common.h
--- src/common.h 30 Oct 2008 14:13:02 -0000 1.107
+++ src/common.h 25 Nov 2008 12:14:39 -0000
@@ -699,8 +699,7 @@ char *xheader_format_name (struct tar_st
void sys_detect_dev_null_output (void);
void sys_save_archive_dev_ino (void);
-void sys_drain_input_pipe (void);
-void sys_wait_for_child (pid_t);
+void sys_wait_for_child (pid_t, bool);
void sys_spawn_shell (void);
bool sys_compare_uid (struct stat *a, struct stat *b);
bool sys_compare_gid (struct stat *a, struct stat *b);
Index: src/system.c
===================================================================
RCS file: /cvsroot/tar/tar/src/system.c,v
retrieving revision 1.25
diff -p -u -r1.25 system.c
--- src/system.c 6 Mar 2008 08:17:34 -0000 1.25
+++ src/system.c 25 Nov 2008 12:14:39 -0000
@@ -51,12 +51,7 @@ sys_detect_dev_null_output (void)
}
void
-sys_drain_input_pipe (void)
-{
-}
-
-void
-sys_wait_for_child (pid_t child_pid)
+sys_wait_for_child (pid_t child_pid, bool eof)
{
}
@@ -160,26 +155,8 @@ sys_detect_dev_null_output (void)
&& archive_stat.st_ino == dev_null_stat.st_ino));
}
-/* Manage to fully drain a pipe we might be reading, so to not break it on
- the producer after the EOF block. FIXME: one of these days, GNU tar
- might become clever enough to just stop working, once there is no more
- work to do, we might have to revise this area in such time. */
-
-void
-sys_drain_input_pipe (void)
-{
- size_t r;
-
- if (access_mode == ACCESS_READ
- && ! _isrmt (archive)
- && (S_ISFIFO (archive_stat.st_mode) || S_ISSOCK (archive_stat.st_mode)))
- while ((r = rmtread (archive, record_start->buffer, record_size)) != 0
- && r != SAFE_READ_ERROR)
- continue;
-}
-
void
-sys_wait_for_child (pid_t child_pid)
+sys_wait_for_child (pid_t child_pid, bool eof)
{
if (child_pid)
{
@@ -193,8 +170,11 @@ sys_wait_for_child (pid_t child_pid)
}
if (WIFSIGNALED (wait_status))
- ERROR ((0, 0, _("Child died with signal %d"),
- WTERMSIG (wait_status)));
+ {
+ int sig = WTERMSIG (wait_status);
+ if (!(!eof && sig == SIGPIPE))
+ ERROR ((0, 0, _("Child died with signal %d"), sig));
+ }
else if (WEXITSTATUS (wait_status) != 0)
ERROR ((0, 0, _("Child returned status %d"),
WEXITSTATUS (wait_status)));