Handle short reads and EOF
authorMichael Meissner <gnu@the-meissners.org>
Mon, 23 Feb 1998 18:21:13 +0000 (18:21 +0000)
committerMichael Meissner <gnu@the-meissners.org>
Mon, 23 Feb 1998 18:21:13 +0000 (18:21 +0000)
sim/common/ChangeLog
sim/common/syscall.c

index 0bf3696f173a6a109dc30e0c2f2fd036754fb060..70af484429ecd419fc4b3ca29c919dcec0f4a42e 100644 (file)
@@ -1,3 +1,7 @@
+Mon Feb 23 13:19:58 1998  Michael Meissner  <meissner@cygnus.com>
+
+       * syscall.c (cb_syscall): Handle short reads, and EOF.
+
 Tue Feb 24 00:29:57 1998  Andrew Cagney  <cagney@b1.cygnus.com>
 
        * sim-trace.c (print_data): case trace_fmt_fp missing break.  Use
index b73cd99b3934fdb995a66e23ae36699e67cc6bb0..0bd891ec2c3496e71f1a2507cbad0ad377799aa0 100644 (file)
@@ -279,6 +279,8 @@ cb_syscall (cb, sc)
                                           ? count : FILE_XFR_SIZE));
            if (result == -1)
              goto ErrorFinish;
+           if (result == 0)    /* EOF */
+             break;
            bytes_written = (*sc->write_mem) (cb, sc, addr, buf, result);
            if (bytes_written != result)
              {
@@ -289,6 +291,9 @@ cb_syscall (cb, sc)
            bytes_read += result;
            count -= result;
            addr += result;
+           /* If this is a short read, don't go back for more */
+           if (result != FILE_XFR_SIZE)
+             break;
          }
        result = bytes_read;
       }
@@ -322,7 +327,7 @@ cb_syscall (cb, sc)
                result = (int) (*cb->write_stdout) (cb, buf, bytes_read);
                (*cb->flush_stdout) (cb);
              }
-           if (fd == 2)
+           else if (fd == 2)
              {
                result = (int) (*cb->write_stderr) (cb, buf, bytes_read);
                (*cb->flush_stderr) (cb);
This page took 0.0334 seconds and 4 git commands to generate.