Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/pkg_install/lib Check the return from read on the f...



details:   https://anonhg.NetBSD.org/src/rev/d056bf3f9fba
branches:  trunk
changeset: 551270:d056bf3f9fba
user:      jlam <jlam%NetBSD.org@localhost>
date:      Wed Sep 03 07:33:37 2003 +0000

description:
Check the return from read on the file descriptor for the ftp process: if
we don't get anything, then it's an error.  From cb%netbsd.org@localhost in private
email.

diffstat:

 usr.sbin/pkg_install/lib/ftpio.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (43 lines):

diff -r 9deffa7fd1f5 -r d056bf3f9fba usr.sbin/pkg_install/lib/ftpio.c
--- a/usr.sbin/pkg_install/lib/ftpio.c  Wed Sep 03 07:29:29 2003 +0000
+++ b/usr.sbin/pkg_install/lib/ftpio.c  Wed Sep 03 07:33:37 2003 +0000
@@ -1,8 +1,8 @@
-/*     $NetBSD: ftpio.c,v 1.53 2003/09/02 07:35:01 jlam Exp $  */
+/*     $NetBSD: ftpio.c,v 1.54 2003/09/03 07:33:37 jlam Exp $  */
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ftpio.c,v 1.53 2003/09/02 07:35:01 jlam Exp $");
+__RCSID("$NetBSD: ftpio.c,v 1.54 2003/09/03 07:33:37 jlam Exp $");
 #endif
 
 /*
@@ -139,12 +139,12 @@
        case -1:
            if (errno == EINTR)
                break;
-           warn("expect: select() failed (probably ftp died because of bad args)");
+           warn("expect: poll() failed (probably ftp died because of bad args)");
            done = 1;
            retval = -1;
            break;
        case 0:
-           warnx("expect: select() timeout");
+           warnx("expect: poll() timeout");
            /* need to send ftp coprocess SIGINT to make it stop
             * downloading into dir that we'll blow away in a second */
            kill(ftp_pid, SIGINT);
@@ -171,7 +171,12 @@
                break;
            }
 
-           rc=read(fd,&buf[sizeof(buf)-1],1);
+           rc = read(fd, &buf[sizeof(buf) - 1], 1);
+           if (rc <= 0) {
+               done = 1;
+               retval = -1;
+               break;
+           }
 
            if (verbose_expect)
                putchar(buf[sizeof(buf)-1]);



Home | Main Index | Thread Index | Old Index