style fix (stray space before ';')
[oweals/busybox.git] / archival / libunarchive / open_transformer.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
4  */
5
6 #include "libbb.h"
7 #include "unarchive.h"
8
9 /* transformer(), more than meets the eye */
10 int open_transformer(int src_fd,
11         USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd))
12 {
13         int fd_pipe[2];
14         int pid;
15
16         xpipe(fd_pipe);
17
18         pid = fork();
19         if (pid == -1) {
20                 bb_perror_msg_and_die("fork failed");
21         }
22
23         if (pid == 0) {
24                 /* child process */
25                 close(fd_pipe[0]); /* We don't wan't to read from the parent */
26                 // FIXME: error check?
27                 transformer(src_fd, fd_pipe[1]);
28                 close(fd_pipe[1]); /* Send EOF */
29                 close(src_fd);
30                 exit(0);
31                 /* notreached */
32         }
33
34         /* parent process */
35         close(fd_pipe[1]); /* Don't want to write to the child */
36
37         return fd_pipe[0];
38 }