aboutsummaryrefslogtreecommitdiff
path: root/compatfd.c
diff options
context:
space:
mode:
authorTristan Gingold <gingold@adacore.com>2011-02-18 14:17:16 +0100
committerBlue Swirl <blauwirbel@gmail.com>2011-02-25 20:16:26 +0000
commit30faaf7073dd51b9e06589d7886696a3f13f201c (patch)
treeaab17c3cf491be09922af383e82dc6d0ff2d19c8 /compatfd.c
parent84803d7a27ef2e83c9b870ebd48e249696909e98 (diff)
Use sigwait instead of sigwaitinfo.
Fix compilation failure on Darwin. Signed-off-by: Tristan Gingold <gingold@adacore.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'compatfd.c')
-rw-r--r--compatfd.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/compatfd.c b/compatfd.c
index a7cebc4867..bd377c411a 100644
--- a/compatfd.c
+++ b/compatfd.c
@@ -26,45 +26,45 @@ struct sigfd_compat_info
static void *sigwait_compat(void *opaque)
{
struct sigfd_compat_info *info = opaque;
- int err;
sigset_t all;
sigfillset(&all);
sigprocmask(SIG_BLOCK, &all, NULL);
- do {
- siginfo_t siginfo;
+ while (1) {
+ int sig;
+ int err;
- err = sigwaitinfo(&info->mask, &siginfo);
- if (err == -1 && errno == EINTR) {
- err = 0;
- continue;
- }
-
- if (err > 0) {
- char buffer[128];
+ err = sigwait(&info->mask, &sig);
+ if (err != 0) {
+ if (errno == EINTR) {
+ continue;
+ } else {
+ return NULL;
+ }
+ } else {
+ struct qemu_signalfd_siginfo buffer;
size_t offset = 0;
- memcpy(buffer, &err, sizeof(err));
+ memset(&buffer, 0, sizeof(buffer));
+ buffer.ssi_signo = sig;
+
while (offset < sizeof(buffer)) {
ssize_t len;
- len = write(info->fd, buffer + offset,
+ len = write(info->fd, (char *)&buffer + offset,
sizeof(buffer) - offset);
if (len == -1 && errno == EINTR)
continue;
if (len <= 0) {
- err = -1;
- break;
+ return NULL;
}
offset += len;
}
}
- } while (err >= 0);
-
- return NULL;
+ }
}
static int qemu_signalfd_compat(const sigset_t *mask)