diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-09-18 19:34:39 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-09-18 19:34:39 +0000 |
commit | 1d96905d761477826688e8bdb94373383539c36f (patch) | |
tree | 33ad04f1643a5a418c31264889a3cac4d33930df /vl.c | |
parent | 99679ececcc633be817cfc4d0bef5c2799ea2ad4 (diff) |
fixed stdio write
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1072 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -1030,10 +1030,30 @@ typedef struct { static int stdio_nb_clients; static CharDriverState *stdio_clients[STDIO_MAX_CLIENTS]; +static int unix_write(int fd, const uint8_t *buf, int len1) +{ + int ret, len; + + len = len1; + while (len > 0) { + ret = write(fd, buf, len); + if (ret < 0) { + if (errno != EINTR && errno != EAGAIN) + return -1; + } else if (ret == 0) { + break; + } else { + buf += ret; + len -= ret; + } + } + return len1 - len; +} + static int fd_chr_write(CharDriverState *chr, const uint8_t *buf, int len) { FDCharDriver *s = chr->opaque; - return write(s->fd_out, buf, len); + return unix_write(s->fd_out, buf, len); } static void fd_chr_add_read_handler(CharDriverState *chr, |