/* Remote target system call support.
- Copyright 1997 Free Software Foundation, Inc.
+ Copyright 1997, 1998 Free Software Foundation, Inc.
Contributed by Cygnus Solutions.
This file is part of GDB.
}
/* Perform a system call on behalf of the target. */
-/* FIXME: TODO: Add magic number to CB_SYSCALL, macro to initialize it,
- and test for the magic number here. */
CB_RC
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)
{
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;
}
goto FinishSyscall;
}
if (fd == 1)
- result = (int) (*cb->write_stdout) (cb, buf, bytes_read);
- if (fd == 2)
- result = (int) (*cb->write_stderr) (cb, buf, bytes_read);
+ {
+ result = (int) (*cb->write_stdout) (cb, buf, bytes_read);
+ (*cb->flush_stdout) (cb);
+ }
+ else if (fd == 2)
+ {
+ result = (int) (*cb->write_stderr) (cb, buf, bytes_read);
+ (*cb->flush_stderr) (cb);
+ }
else
result = (int) (*cb->write) (cb, fd, buf, bytes_read);
if (result == -1)