aboutsummaryrefslogtreecommitdiff
path: root/libbb/gz_open.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/gz_open.c')
-rw-r--r--libbb/gz_open.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libbb/gz_open.c b/libbb/gz_open.c
index 19ec0a066..b23920b16 100644
--- a/libbb/gz_open.c
+++ b/libbb/gz_open.c
@@ -6,17 +6,17 @@
6#include <unistd.h> 6#include <unistd.h>
7#include "libbb.h" 7#include "libbb.h"
8 8
9extern int gz_open(FILE *compressed_file, int *pid) 9extern FILE *gz_open(FILE *compressed_file, int *pid)
10{ 10{
11 int unzip_pipe[2]; 11 int unzip_pipe[2];
12 12
13 if (pipe(unzip_pipe)!=0) { 13 if (pipe(unzip_pipe)!=0) {
14 error_msg("pipe error"); 14 error_msg("pipe error");
15 return(EXIT_FAILURE); 15 return(NULL);
16 } 16 }
17 if ((*pid = fork()) == -1) { 17 if ((*pid = fork()) == -1) {
18 error_msg("fork failured"); 18 error_msg("fork failured");
19 return(EXIT_FAILURE); 19 return(NULL);
20 } 20 }
21 if (*pid==0) { 21 if (*pid==0) {
22 /* child process */ 22 /* child process */
@@ -27,7 +27,9 @@ extern int gz_open(FILE *compressed_file, int *pid)
27 close(unzip_pipe[1]); 27 close(unzip_pipe[1]);
28 exit(EXIT_SUCCESS); 28 exit(EXIT_SUCCESS);
29 } 29 }
30
31 close(unzip_pipe[1]); 30 close(unzip_pipe[1]);
32 return(unzip_pipe[0]); 31 if (unzip_pipe[0] == -1) {
33} \ No newline at end of file 32 error_msg("Couldnt initialise gzip stream");
33 }
34 return(fdopen(unzip_pipe[0], "r"));
35}