tar: fix a thinko in prev commit - we need to copy to _unused_ fd
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 4 Aug 2018 19:06:02 +0000 (21:06 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 4 Aug 2018 19:06:02 +0000 (21:06 +0200)
function                                             old     new   delta
vfork_compressor                                     257     246     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
archival/tar.c

index 120c77f3bea95776e8eb49dea5dab34dff8f2aaa..1c71f7f661a8176e84086d46de8ea2a6f2de0297 100644 (file)
@@ -632,8 +632,7 @@ static void NOINLINE vfork_compressor(int tar_fd, const char *gzip)
                         * Swapping move_fd's order wouldn't work:
                         * data.rd is 1 and _it_ would be destroyed.
                         */
-                       xmove_fd(tfd, 3);
-                       tfd = 3;
+                       tfd = dup(tfd);
                }
                xmove_fd(data.rd, 0);
                xmove_fd(tfd, 1);