Close unused pipe handle before fork (for tar -z).
authorGlenn L McGrath <bug1@ihug.co.nz>
Sat, 20 Jan 2001 00:12:21 +0000 (00:12 -0000)
committerGlenn L McGrath <bug1@ihug.co.nz>
Sat, 20 Jan 2001 00:12:21 +0000 (00:12 -0000)
archival/tar.c
tar.c

index 844559580faf031c872663f64b27ebdf4f6c850b..49e99a1a5a4740cd98bbe8ee10d1c89b91511d4f 100644 (file)
@@ -169,13 +169,16 @@ extern int tar_unzip_init(int tarFd)
 
        if (child_pid==0) {
                /* child process */
+               close(unzip_pipe[0]);
                gunzip_init();
                unzip(tarFd, unzip_pipe[1]);
                exit(EXIT_SUCCESS);
        }
-       else
+       else {
                /* return fd of uncompressed data to parent process */
+               close(unzip_pipe[1]);
                return(unzip_pipe[0]);
+       }
 }
 #endif
 
diff --git a/tar.c b/tar.c
index 844559580faf031c872663f64b27ebdf4f6c850b..49e99a1a5a4740cd98bbe8ee10d1c89b91511d4f 100644 (file)
--- a/tar.c
+++ b/tar.c
@@ -169,13 +169,16 @@ extern int tar_unzip_init(int tarFd)
 
        if (child_pid==0) {
                /* child process */
+               close(unzip_pipe[0]);
                gunzip_init();
                unzip(tarFd, unzip_pipe[1]);
                exit(EXIT_SUCCESS);
        }
-       else
+       else {
                /* return fd of uncompressed data to parent process */
+               close(unzip_pipe[1]);
                return(unzip_pipe[0]);
+       }
 }
 #endif