Commit 1d96905d761477826688e8bdb94373383539c36f

Authored by bellard
1 parent 99679ece

fixed stdio write


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1072 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 21 additions and 1 deletions
... ... @@ -1030,10 +1030,30 @@ typedef struct {
1030 1030 static int stdio_nb_clients;
1031 1031 static CharDriverState *stdio_clients[STDIO_MAX_CLIENTS];
1032 1032  
  1033 +static int unix_write(int fd, const uint8_t *buf, int len1)
  1034 +{
  1035 + int ret, len;
  1036 +
  1037 + len = len1;
  1038 + while (len > 0) {
  1039 + ret = write(fd, buf, len);
  1040 + if (ret < 0) {
  1041 + if (errno != EINTR && errno != EAGAIN)
  1042 + return -1;
  1043 + } else if (ret == 0) {
  1044 + break;
  1045 + } else {
  1046 + buf += ret;
  1047 + len -= ret;
  1048 + }
  1049 + }
  1050 + return len1 - len;
  1051 +}
  1052 +
1033 1053 static int fd_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
1034 1054 {
1035 1055 FDCharDriver *s = chr->opaque;
1036   - return write(s->fd_out, buf, len);
  1056 + return unix_write(s->fd_out, buf, len);
1037 1057 }
1038 1058  
1039 1059 static void fd_chr_add_read_handler(CharDriverState *chr,
... ...