Revision 7b5f699d osdep.c

b/osdep.c
243 243
    return ret;
244 244
}
245 245

  
246
/*
247
 * A variant of write(2) which handles partial write.
248
 *
249
 * Return the number of bytes transferred.
250
 * Set errno if fewer than `count' bytes are written.
251
 */
252
ssize_t qemu_write_full(int fd, const void *buf, size_t count)
253
{
254
    ssize_t ret = 0;
255
    ssize_t total = 0;
256

  
257
    while (count) {
258
        ret = write(fd, buf, count);
259
        if (ret < 0) {
260
            if (errno == EINTR)
261
                continue;
262
            break;
263
        }
264

  
265
        count -= ret;
266
        buf += ret;
267
        total += ret;
268
    }
269

  
270
    return total;
271
}
272

  
246 273
#ifndef _WIN32
247 274
/*
248 275
 * Creates a pipe with FD_CLOEXEC set on both file descriptors

Also available in: Unified diff