diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-09-16 18:50:56 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-09-16 18:50:56 +0000 |
commit | e755e827f7c8ecb21787a4369d7afdeda54d112b (patch) | |
tree | 007b1506e69ffcc25bc6ba3b0e6686d806a34264 /archival/libunarchive/open_transformer.c | |
parent | ed6ac53104d811ee88c71aff45c7cad666aaee46 (diff) | |
download | busybox-w32-1_7_1.tar.gz busybox-w32-1_7_1.tar.bz2 busybox-w32-1_7_1.zip |
apply post 1.7.0 patches, set version to 1.7.11_7_1
Diffstat (limited to 'archival/libunarchive/open_transformer.c')
-rw-r--r-- | archival/libunarchive/open_transformer.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/archival/libunarchive/open_transformer.c b/archival/libunarchive/open_transformer.c index 0ee080621..f8f587e8d 100644 --- a/archival/libunarchive/open_transformer.c +++ b/archival/libunarchive/open_transformer.c | |||
@@ -7,27 +7,48 @@ | |||
7 | #include "unarchive.h" | 7 | #include "unarchive.h" |
8 | 8 | ||
9 | /* transformer(), more than meets the eye */ | 9 | /* transformer(), more than meets the eye */ |
10 | /* | ||
11 | * On MMU machine, the transform_prog and ... are stripped | ||
12 | * by a macro in include/unarchive.h. On NOMMU, transformer is stripped. | ||
13 | */ | ||
10 | int open_transformer(int src_fd, | 14 | int open_transformer(int src_fd, |
11 | USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd)) | 15 | USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd), |
16 | const char *transform_prog, ...) | ||
12 | { | 17 | { |
13 | int fd_pipe[2]; | 18 | int fd_pipe[2]; |
14 | int pid; | 19 | int pid; |
15 | 20 | ||
16 | xpipe(fd_pipe); | 21 | xpipe(fd_pipe); |
17 | 22 | ||
23 | #if BB_MMU | ||
18 | pid = fork(); | 24 | pid = fork(); |
19 | if (pid == -1) { | 25 | #else |
26 | pid = vfork(); | ||
27 | #endif | ||
28 | if (pid == -1) | ||
20 | bb_perror_msg_and_die("fork failed"); | 29 | bb_perror_msg_and_die("fork failed"); |
21 | } | ||
22 | 30 | ||
23 | if (pid == 0) { | 31 | if (pid == 0) { |
32 | #if !BB_MMU | ||
33 | va_list ap; | ||
34 | #endif | ||
24 | /* child process */ | 35 | /* child process */ |
25 | close(fd_pipe[0]); /* We don't wan't to read from the parent */ | 36 | close(fd_pipe[0]); /* We don't wan't to read from the parent */ |
26 | // FIXME: error check? | 37 | // FIXME: error check? |
38 | #if BB_MMU | ||
27 | transformer(src_fd, fd_pipe[1]); | 39 | transformer(src_fd, fd_pipe[1]); |
28 | close(fd_pipe[1]); /* Send EOF */ | 40 | if (ENABLE_FEATURE_CLEAN_UP) { |
29 | close(src_fd); | 41 | close(fd_pipe[1]); /* Send EOF */ |
42 | close(src_fd); | ||
43 | } | ||
30 | exit(0); | 44 | exit(0); |
45 | #else | ||
46 | xmove_fd(src_fd, 0); | ||
47 | xmove_fd(fd_pipe[1], 1); | ||
48 | va_start(ap, transform_prog); | ||
49 | BB_EXECVP(transform_prog, ap); | ||
50 | bb_perror_and_die("exec failed"); | ||
51 | #endif | ||
31 | /* notreached */ | 52 | /* notreached */ |
32 | } | 53 | } |
33 | 54 | ||