1 /* vi: set sw=4 ts=4: */
3 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 /* transformer(), more than meets the eye */
11 * On MMU machine, the transform_prog is removed by macro magic
12 * in include/archive.h. On NOMMU, transformer is removed.
14 void FAST_FUNC open_transformer(int fd,
15 IF_DESKTOP(long long) int FAST_FUNC (*transformer)(int src_fd, int dst_fd),
16 const char *transform_prog)
18 struct fd_pair fd_pipe;
22 pid = BB_MMU ? xfork() : xvfork();
25 close(fd_pipe.rd); /* we don't want to read from the parent */
26 // FIXME: error check?
28 transformer(fd, fd_pipe.wr);
29 if (ENABLE_FEATURE_CLEAN_UP) {
30 close(fd_pipe.wr); /* send EOF */
33 /* must be _exit! bug was actually seen here */
39 xmove_fd(fd_pipe.wr, 1);
40 argv[0] = (char*)transform_prog;
41 argv[1] = (char*)"-cf";
44 BB_EXECVP(transform_prog, argv);
45 bb_perror_msg_and_die("can't execute '%s'", transform_prog);
52 close(fd_pipe.wr); /* don't want to write to the child */
53 xmove_fd(fd_pipe.rd, fd);