From 534374755d618c9c36c9940c82756241c4b25a67 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 16 Jul 2006 08:14:35 +0000 Subject: Cleaup read() and write() variants, plus a couple of new functions like xlseek and fdlength() for the new mkswap. --- networking/nc.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'networking/nc.c') 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 @@ #include "busybox.h" -#define xread bb_xread - static void timeout(int signum) { bb_error_msg_and_die("Timed out"); @@ -151,13 +149,14 @@ repeatyness: for (fd = 0; fd < FD_SETSIZE; fd++) { if (FD_ISSET(fd, &testfds)) { - nread = xread(fd, bb_common_bufsiz1, sizeof(bb_common_bufsiz1)); + nread = safe_read(fd, bb_common_bufsiz1, + sizeof(bb_common_bufsiz1)); if (fd == cfd) { - if (!nread) exit(0); + if (nread<1) exit(0); ofd = STDOUT_FILENO; } else { - if (!nread) { + if (nread<1) { // Close outgoing half-connection so they get EOF, but // leave incoming alone so we can see response. shutdown(cfd, 1); @@ -166,8 +165,7 @@ repeatyness: ofd = cfd; } - if (bb_full_write(ofd, bb_common_bufsiz1, nread) < 0) - bb_perror_msg_and_die(bb_msg_write_error); + xwrite(ofd, bb_common_bufsiz1, nread); if (delay > 0) sleep(delay); } } -- cgit v1.2.3-55-g6feb