Submitted By: Jim Gifford (jim at cross-lfs dot org)
Date: 2009-01-04
Initial Package Version: 1.21
Origin: Tar Bug List
Upstream Status: Applied
Description: http://lists.gnu.org/archive/html/bug-tar/2008-12/msg00028.html
diff -Naur tar-1.21.orig/src/buffer.c tar-1.21/src/buffer.c
old
|
new
|
|
848 | 848 | flush_archive (); |
849 | 849 | } |
850 | 850 | |
| 851 | sys_drain_input_pipe (); |
| 852 | |
851 | 853 | compute_duration (); |
852 | 854 | if (verify_option) |
853 | 855 | verify_volume (); |
… |
… |
|
855 | 857 | if (rmtclose (archive) != 0) |
856 | 858 | close_error (*archive_name_cursor); |
857 | 859 | |
858 | | sys_wait_for_child (child_pid, hit_eof); |
| 860 | sys_wait_for_child (child_pid); |
859 | 861 | |
860 | 862 | tar_stat_destroy (¤t_stat_info); |
861 | 863 | if (save_name) |
diff -Naur tar-1.21.orig/src/common.h tar-1.21/src/common.h
old
|
new
|
|
699 | 699 | |
700 | 700 | void sys_detect_dev_null_output (void); |
701 | 701 | void sys_save_archive_dev_ino (void); |
702 | | void sys_wait_for_child (pid_t, bool); |
| 702 | void sys_drain_input_pipe (void); |
| 703 | void sys_wait_for_child (pid_t); |
703 | 704 | void sys_spawn_shell (void); |
704 | 705 | bool sys_compare_uid (struct stat *a, struct stat *b); |
705 | 706 | bool sys_compare_gid (struct stat *a, struct stat *b); |
diff -Naur tar-1.21.orig/src/system.c tar-1.21/src/system.c
old
|
new
|
|
1 | 1 | /* System-dependent calls for tar. |
2 | 2 | |
3 | | Copyright (C) 2003, 2004, 2005, 2006, 2007, |
4 | | 2008 Free Software Foundation, Inc. |
| 3 | Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
5 | 4 | |
6 | 5 | This program is free software; you can redistribute it and/or modify it |
7 | 6 | under the terms of the GNU General Public License as published by the |
… |
… |
|
52 | 51 | } |
53 | 52 | |
54 | 53 | void |
55 | | sys_wait_for_child (pid_t child_pid, bool eof) |
| 54 | sys_drain_input_pipe (void) |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | void |
| 59 | sys_wait_for_child (pid_t child_pid) |
56 | 60 | { |
57 | 61 | } |
58 | 62 | |
… |
… |
|
156 | 160 | && archive_stat.st_ino == dev_null_stat.st_ino)); |
157 | 161 | } |
158 | 162 | |
| 163 | /* Manage to fully drain a pipe we might be reading, so to not break it on |
| 164 | the producer after the EOF block. FIXME: one of these days, GNU tar |
| 165 | might become clever enough to just stop working, once there is no more |
| 166 | work to do, we might have to revise this area in such time. */ |
| 167 | |
| 168 | void |
| 169 | sys_drain_input_pipe (void) |
| 170 | { |
| 171 | size_t r; |
| 172 | |
| 173 | if (access_mode == ACCESS_READ |
| 174 | && ! _isrmt (archive) |
| 175 | && (S_ISFIFO (archive_stat.st_mode) || S_ISSOCK (archive_stat.st_mode))) |
| 176 | while ((r = rmtread (archive, record_start->buffer, record_size)) != 0 |
| 177 | && r != SAFE_READ_ERROR) |
| 178 | continue; |
| 179 | } |
| 180 | |
159 | 181 | void |
160 | | sys_wait_for_child (pid_t child_pid, bool eof) |
| 182 | sys_wait_for_child (pid_t child_pid) |
161 | 183 | { |
162 | 184 | if (child_pid) |
163 | 185 | { |
… |
… |
|
171 | 193 | } |
172 | 194 | |
173 | 195 | if (WIFSIGNALED (wait_status)) |
174 | | { |
175 | | int sig = WTERMSIG (wait_status); |
176 | | if (!(!eof && sig == SIGPIPE)) |
177 | | ERROR ((0, 0, _("Child died with signal %d"), sig)); |
178 | | } |
| 196 | ERROR ((0, 0, _("Child died with signal %d"), |
| 197 | WTERMSIG (wait_status))); |
179 | 198 | else if (WEXITSTATUS (wait_status) != 0) |
180 | 199 | ERROR ((0, 0, _("Child returned status %d"), |
181 | 200 | WEXITSTATUS (wait_status))); |