diff options
author | Rob Landley <rob@landley.net> | 2006-07-16 08:14:35 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-07-16 08:14:35 +0000 |
commit | 534374755d618c9c36c9940c82756241c4b25a67 (patch) | |
tree | fac906b4fa40a68c53cecf20215a7a25b3b1cab6 /networking/nc.c | |
parent | afb94ecf2bb6c53ce2a381d6ce45a426243c76d9 (diff) | |
download | busybox-w32-534374755d618c9c36c9940c82756241c4b25a67.tar.gz busybox-w32-534374755d618c9c36c9940c82756241c4b25a67.tar.bz2 busybox-w32-534374755d618c9c36c9940c82756241c4b25a67.zip |
Cleaup read() and write() variants, plus a couple of new functions like
xlseek and fdlength() for the new mkswap.
Diffstat (limited to 'networking/nc.c')
-rw-r--r-- | networking/nc.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/networking/nc.c b/networking/nc.c index bda0c407b..117bbe20e 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -9,8 +9,6 @@ | |||
9 | 9 | ||
10 | #include "busybox.h" | 10 | #include "busybox.h" |
11 | 11 | ||
12 | #define xread bb_xread | ||
13 | |||
14 | static void timeout(int signum) | 12 | static void timeout(int signum) |
15 | { | 13 | { |
16 | bb_error_msg_and_die("Timed out"); | 14 | bb_error_msg_and_die("Timed out"); |
@@ -151,13 +149,14 @@ repeatyness: | |||
151 | 149 | ||
152 | for (fd = 0; fd < FD_SETSIZE; fd++) { | 150 | for (fd = 0; fd < FD_SETSIZE; fd++) { |
153 | if (FD_ISSET(fd, &testfds)) { | 151 | if (FD_ISSET(fd, &testfds)) { |
154 | nread = xread(fd, bb_common_bufsiz1, sizeof(bb_common_bufsiz1)); | 152 | nread = safe_read(fd, bb_common_bufsiz1, |
153 | sizeof(bb_common_bufsiz1)); | ||
155 | 154 | ||
156 | if (fd == cfd) { | 155 | if (fd == cfd) { |
157 | if (!nread) exit(0); | 156 | if (nread<1) exit(0); |
158 | ofd = STDOUT_FILENO; | 157 | ofd = STDOUT_FILENO; |
159 | } else { | 158 | } else { |
160 | if (!nread) { | 159 | if (nread<1) { |
161 | // Close outgoing half-connection so they get EOF, but | 160 | // Close outgoing half-connection so they get EOF, but |
162 | // leave incoming alone so we can see response. | 161 | // leave incoming alone so we can see response. |
163 | shutdown(cfd, 1); | 162 | shutdown(cfd, 1); |
@@ -166,8 +165,7 @@ repeatyness: | |||
166 | ofd = cfd; | 165 | ofd = cfd; |
167 | } | 166 | } |
168 | 167 | ||
169 | if (bb_full_write(ofd, bb_common_bufsiz1, nread) < 0) | 168 | xwrite(ofd, bb_common_bufsiz1, nread); |
170 | bb_perror_msg_and_die(bb_msg_write_error); | ||
171 | if (delay > 0) sleep(delay); | 169 | if (delay > 0) sleep(delay); |
172 | } | 170 | } |
173 | } | 171 | } |