mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-31 05:51:53 -06:00
util: simplify write in signal handler
Use qemu_write_full() instead of open-coding a write loop. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20220420132624.2439741-36-marcandre.lureau@redhat.com>
This commit is contained in:
parent
c3e5704af1
commit
d0dedf2f4c
1 changed files with 2 additions and 16 deletions
|
@ -42,26 +42,12 @@ static void *sigwait_compat(void *opaque)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
struct qemu_signalfd_siginfo buffer;
|
struct qemu_signalfd_siginfo buffer;
|
||||||
size_t offset = 0;
|
|
||||||
|
|
||||||
memset(&buffer, 0, sizeof(buffer));
|
memset(&buffer, 0, sizeof(buffer));
|
||||||
buffer.ssi_signo = sig;
|
buffer.ssi_signo = sig;
|
||||||
|
|
||||||
while (offset < sizeof(buffer)) {
|
if (qemu_write_full(info->fd, &buffer, sizeof(buffer)) != sizeof(buffer)) {
|
||||||
ssize_t len;
|
|
||||||
|
|
||||||
len = write(info->fd, (char *)&buffer + offset,
|
|
||||||
sizeof(buffer) - offset);
|
|
||||||
if (len == -1 && errno == EINTR) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len <= 0) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += len;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue