diff options
author | Denis Vlasenko | 2008-02-16 13:20:56 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-02-16 13:20:56 +0000 |
commit | 3718832a1542f7bf786a1678741b8566ad3a35c6 (patch) | |
tree | ac5851de53237fb3a0c77c9cead27acd279897f0 /networking/ifupdown.c | |
parent | 1e18f1bab3400246129756a35bb5752ba98f4c90 (diff) | |
download | busybox-3718832a1542f7bf786a1678741b8566ad3a35c6.zip busybox-3718832a1542f7bf786a1678741b8566ad3a35c6.tar.gz |
*: more readable handling of pipe fds. No code changes.
Diffstat (limited to 'networking/ifupdown.c')
-rw-r--r-- | networking/ifupdown.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index d0d7bfe..58e6953 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c @@ -987,11 +987,11 @@ static int iface_down(struct interface_defn_t *iface) static int popen2(FILE **in, FILE **out, char *command, char *param) { char *argv[3] = { command, param, NULL }; - int infd[2], outfd[2]; + struct fd_pair infd, outfd; pid_t pid; - xpipe(infd); - xpipe(outfd); + xpiped_pair(infd); + xpiped_pair(outfd); fflush(NULL); pid = fork(); @@ -1001,18 +1001,18 @@ static int popen2(FILE **in, FILE **out, char *command, char *param) bb_perror_msg_and_die("fork"); case 0: /* child */ /* NB: close _first_, then move fds! */ - close(infd[1]); - close(outfd[0]); - xmove_fd(infd[0], 0); - xmove_fd(outfd[1], 1); + close(infd.wr); + close(outfd.rd); + xmove_fd(infd.rd, 0); + xmove_fd(outfd.wr, 1); BB_EXECVP(command, argv); _exit(127); } /* parent */ - close(infd[0]); - close(outfd[1]); - *in = fdopen(infd[1], "w"); - *out = fdopen(outfd[0], "r"); + close(infd.rd); + close(outfd.wr); + *in = fdopen(infd.wr, "w"); + *out = fdopen(outfd.rd, "r"); return pid; } |