diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-16 13:20:56 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-16 13:20:56 +0000 |
commit | 3718832a1542f7bf786a1678741b8566ad3a35c6 (patch) | |
tree | ac5851de53237fb3a0c77c9cead27acd279897f0 /runit/runsvdir.c | |
parent | 1e18f1bab3400246129756a35bb5752ba98f4c90 (diff) | |
download | busybox-w32-3718832a1542f7bf786a1678741b8566ad3a35c6.tar.gz busybox-w32-3718832a1542f7bf786a1678741b8566ad3a35c6.tar.bz2 busybox-w32-3718832a1542f7bf786a1678741b8566ad3a35c6.zip |
*: more readable handling of pipe fds. No code changes.
Diffstat (limited to 'runit/runsvdir.c')
-rw-r--r-- | runit/runsvdir.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/runit/runsvdir.c b/runit/runsvdir.c index 838490376..4225ac101 100644 --- a/runit/runsvdir.c +++ b/runit/runsvdir.c | |||
@@ -47,7 +47,7 @@ static char *svdir; | |||
47 | static int svnum; | 47 | static int svnum; |
48 | static char *rplog; | 48 | static char *rplog; |
49 | static int rploglen; | 49 | static int rploglen; |
50 | static int logpipe[2]; | 50 | static struct fd_pair logpipe; |
51 | static struct pollfd pfd[1]; | 51 | static struct pollfd pfd[1]; |
52 | static unsigned stamplog; | 52 | static unsigned stamplog; |
53 | static smallint check = 1; | 53 | static smallint check = 1; |
@@ -186,19 +186,19 @@ static int setup_log(void) | |||
186 | warnx("log must have at least seven characters"); | 186 | warnx("log must have at least seven characters"); |
187 | return 0; | 187 | return 0; |
188 | } | 188 | } |
189 | if (pipe(logpipe)) { | 189 | if (piped_pair(logpipe)) { |
190 | warnx("cannot create pipe for log"); | 190 | warnx("cannot create pipe for log"); |
191 | return -1; | 191 | return -1; |
192 | } | 192 | } |
193 | close_on_exec_on(logpipe[1]); | 193 | close_on_exec_on(logpipe.rd); |
194 | close_on_exec_on(logpipe[0]); | 194 | close_on_exec_on(logpipe.wr); |
195 | ndelay_on(logpipe[0]); | 195 | ndelay_on(logpipe.rd); |
196 | ndelay_on(logpipe[1]); | 196 | ndelay_on(logpipe.wr); |
197 | if (dup2(logpipe[1], 2) == -1) { | 197 | if (dup2(logpipe.wr, 2) == -1) { |
198 | warnx("cannot set filedescriptor for log"); | 198 | warnx("cannot set filedescriptor for log"); |
199 | return -1; | 199 | return -1; |
200 | } | 200 | } |
201 | pfd[0].fd = logpipe[0]; | 201 | pfd[0].fd = logpipe.rd; |
202 | pfd[0].events = POLLIN; | 202 | pfd[0].events = POLLIN; |
203 | stamplog = monotonic_sec(); | 203 | stamplog = monotonic_sec(); |
204 | return 1; | 204 | return 1; |
@@ -296,7 +296,7 @@ int runsvdir_main(int argc, char **argv) | |||
296 | 296 | ||
297 | if (rplog) { | 297 | if (rplog) { |
298 | if ((int)(now - stamplog) >= 0) { | 298 | if ((int)(now - stamplog) >= 0) { |
299 | write(logpipe[1], ".", 1); | 299 | write(logpipe.wr, ".", 1); |
300 | stamplog = now + 900; | 300 | stamplog = now + 900; |
301 | } | 301 | } |
302 | } | 302 | } |
@@ -311,7 +311,7 @@ int runsvdir_main(int argc, char **argv) | |||
311 | sig_unblock(SIGCHLD); | 311 | sig_unblock(SIGCHLD); |
312 | 312 | ||
313 | if (pfd[0].revents & POLLIN) { | 313 | if (pfd[0].revents & POLLIN) { |
314 | while (read(logpipe[0], &ch, 1) > 0) { | 314 | while (read(logpipe.rd, &ch, 1) > 0) { |
315 | if (ch) { | 315 | if (ch) { |
316 | for (i = 6; i < rploglen; i++) | 316 | for (i = 6; i < rploglen; i++) |
317 | rplog[i-1] = rplog[i]; | 317 | rplog[i-1] = rplog[i]; |