[email protected] said: > [email protected] said: > > Wouldn't your patch result in the signal thread sleeping forever in > > the scenario you describe? I'm not saying it shouldn't, it just not > > what the patch immediately reads like in conjunction with your > > description. > > Yes, that is the intention, in the first instance.
And this is the working version, now pushed to the staging-mysql branch. I've improved the error handling to return the correct errno in all cases and made it clear in the commit log that the thread will be sent to sleep indefinitely if no timeout is specified. Okay to merge? commit c2155d4e06340ca66897f59698eddfdc22aabd0b Author: Martin Lucina <[email protected]> Date: Thu Mar 12 11:53:26 2015 +0100 Implement sigtimedwait() Given that we have no signals, this just sends the calling thread to sleep and always returns EAGAIN if the timeout period expired. If no timeout is given the thread will sleep forever. Signed-off-by: Martin Lucina <[email protected]> diff --git a/platform/xen/lib/emul.c b/platform/xen/lib/emul.c index 7b3fdc1..3ec0008 100644 --- a/platform/xen/lib/emul.c +++ b/platform/xen/lib/emul.c @@ -14,7 +14,10 @@ #include <errno.h> #include <fcntl.h> +#include <lwp.h> +#include <signal.h> #include <stdlib.h> +#include <time.h> #include <unistd.h> #include <mini-os/os.h> /* for PAGE_SIZE */ @@ -108,3 +111,17 @@ _exit(int eval) minios_stop_kernel(); minios_do_halt(MINIOS_HALT_POWEROFF); } + +int ____sigtimedwait50(const sigset_t *set, siginfo_t *info, + const struct timespec *timeout) +{ + int rc; + rc = _lwp_park(CLOCK_MONOTONIC, 0, timeout, NULL, NULL, NULL); + if (rc == -1) { + if (errno == ETIMEDOUT) + errno = EAGAIN; + } else { + errno = EAGAIN; + } + return -1; +} diff --git a/platform/xen/lib/libc_stubs.c b/platform/xen/lib/libc_stubs.c index b1cb901..973e4a6 100644 --- a/platform/xen/lib/libc_stubs.c +++ b/platform/xen/lib/libc_stubs.c @@ -34,4 +34,3 @@ STUB(_sys_msgsnd); STUB(_sys___msync13); STUB(_sys___wait450); STUB(_sys___sigsuspend14); -STUB(____sigtimedwait50);
