blob: 19ec0a066fded86f9eb7605f592898881ca59e0c [file] [log] [blame]
Glenn L McGrath7fd92942001-04-11 03:11:33 +00001#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
9extern 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 McGrath7fd92942001-04-11 03:11:33 +000025 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}