On Wed, Feb 15, 2023 at 03:11:35PM +0100, Laszlo Ersek wrote:
While nbd_internal_fork_safe_perror() must indeed call write(), and arguably justifiedly ignores the return value of write(), we can still make the write operations slightly more robust. Let's do that by introducing xwrite():
- don't call write() with nbyte > SSIZE_MAX, for avoiding implementation-defined behavior,
- handle partial writes,
- cope with EINTR and EAGAIN errors. (A busy loop around EAGAIN on a non-blocking file is not great in the general case, but it's good enough for writing out diagnostics before giving up.)
Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- lib/utils.c | 39 ++++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-)
Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org