Glenn L McGrath | 7fd9294 | 2001-04-11 03:11:33 +0000 | [diff] [blame] | 1 | #include <sys/types.h> |
| 2 | #include <sys/wait.h> |
| 3 | #include <signal.h> |
| 4 | #include <stdlib.h> |
| 5 | #include <string.h> |
| 6 | #include <unistd.h> |
| 7 | #include "libbb.h" |
| 8 | |
| 9 | extern int gz_open(FILE *compressed_file, int *pid) |
| 10 | { |
| 11 | int unzip_pipe[2]; |
| 12 | |
| 13 | if (pipe(unzip_pipe)!=0) { |
| 14 | error_msg("pipe error"); |
| 15 | return(EXIT_FAILURE); |
| 16 | } |
| 17 | if ((*pid = fork()) == -1) { |
| 18 | error_msg("fork failured"); |
| 19 | return(EXIT_FAILURE); |
| 20 | } |
| 21 | if (*pid==0) { |
| 22 | /* child process */ |
| 23 | close(unzip_pipe[0]); |
| 24 | unzip(compressed_file, fdopen(unzip_pipe[1], "w")); |
Glenn L McGrath | 7fd9294 | 2001-04-11 03:11:33 +0000 | [diff] [blame] | 25 | fflush(NULL); |
| 26 | fclose(compressed_file); |
| 27 | close(unzip_pipe[1]); |
| 28 | exit(EXIT_SUCCESS); |
| 29 | } |
| 30 | |
| 31 | close(unzip_pipe[1]); |
| 32 | return(unzip_pipe[0]); |
| 33 | } |