aboutsummaryrefslogtreecommitdiff
path: root/sim/common/syscall.c
diff options
context:
space:
mode:
authorMichael Meissner <gnu@the-meissners.org>1998-02-23 18:21:13 +0000
committerMichael Meissner <gnu@the-meissners.org>1998-02-23 18:21:13 +0000
commit3aeca4624a9ccaaa084b3d7c619b60dcbcd915b7 (patch)
tree503d7cc7b0c04db31425e0b5631bc50f059e854b /sim/common/syscall.c
parentf33a8aa5677cf501739e196542c45bc46322a168 (diff)
downloadgdb-3aeca4624a9ccaaa084b3d7c619b60dcbcd915b7.zip
gdb-3aeca4624a9ccaaa084b3d7c619b60dcbcd915b7.tar.gz
gdb-3aeca4624a9ccaaa084b3d7c619b60dcbcd915b7.tar.bz2
Handle short reads and EOF
Diffstat (limited to 'sim/common/syscall.c')
-rw-r--r--sim/common/syscall.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sim/common/syscall.c b/sim/common/syscall.c
index b73cd99..0bd891e 100644
--- a/sim/common/syscall.c
+++ b/sim/common/syscall.c
@@ -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);