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>
This commit is contained in:
parent
84803d7a27
commit
30faaf7073
32
compatfd.c
32
compatfd.c
@ -26,45 +26,45 @@ struct sigfd_compat_info
|
|||||||
static void *sigwait_compat(void *opaque)
|
static void *sigwait_compat(void *opaque)
|
||||||
{
|
{
|
||||||
struct sigfd_compat_info *info = opaque;
|
struct sigfd_compat_info *info = opaque;
|
||||||
int err;
|
|
||||||
sigset_t all;
|
sigset_t all;
|
||||||
|
|
||||||
sigfillset(&all);
|
sigfillset(&all);
|
||||||
sigprocmask(SIG_BLOCK, &all, NULL);
|
sigprocmask(SIG_BLOCK, &all, NULL);
|
||||||
|
|
||||||
do {
|
while (1) {
|
||||||
siginfo_t siginfo;
|
int sig;
|
||||||
|
int err;
|
||||||
|
|
||||||
err = sigwaitinfo(&info->mask, &siginfo);
|
err = sigwait(&info->mask, &sig);
|
||||||
if (err == -1 && errno == EINTR) {
|
if (err != 0) {
|
||||||
err = 0;
|
if (errno == EINTR) {
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (err > 0) {
|
struct qemu_signalfd_siginfo buffer;
|
||||||
char buffer[128];
|
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
|
|
||||||
memcpy(buffer, &err, sizeof(err));
|
memset(&buffer, 0, sizeof(buffer));
|
||||||
|
buffer.ssi_signo = sig;
|
||||||
|
|
||||||
while (offset < sizeof(buffer)) {
|
while (offset < sizeof(buffer)) {
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
|
||||||
len = write(info->fd, buffer + offset,
|
len = write(info->fd, (char *)&buffer + offset,
|
||||||
sizeof(buffer) - offset);
|
sizeof(buffer) - offset);
|
||||||
if (len == -1 && errno == EINTR)
|
if (len == -1 && errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
err = -1;
|
return NULL;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += len;
|
offset += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (err >= 0);
|
}
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qemu_signalfd_compat(const sigset_t *mask)
|
static int qemu_signalfd_compat(const sigset_t *mask)
|
||||||
|
Loading…
Reference in New Issue
Block a user