summaryrefslogtreecommitdiff
path: root/lib/mlibc/tests/posix/sigtimedwait.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:52 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 18:24:51 -0500
commitf5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 (patch)
tree93b156621dc0303816b37f60ba88051b702d92f6 /lib/mlibc/tests/posix/sigtimedwait.c
parentbd5969fc876a10b18613302db7087ef3c40f18e1 (diff)
build: Build mlibc + add distclean target
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/tests/posix/sigtimedwait.c')
-rw-r--r--lib/mlibc/tests/posix/sigtimedwait.c91
1 files changed, 0 insertions, 91 deletions
diff --git a/lib/mlibc/tests/posix/sigtimedwait.c b/lib/mlibc/tests/posix/sigtimedwait.c
deleted file mode 100644
index 4793fc1..0000000
--- a/lib/mlibc/tests/posix/sigtimedwait.c
+++ /dev/null
@@ -1,91 +0,0 @@
-#include <stdio.h>
-
-#include <assert.h>
-#include <signal.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <errno.h>
-
-pid_t parent;
-pid_t child;
-
-int fds[2];
-
-void parent_fn() {
- int res;
-
- sigset_t set;
- sigemptyset(&set);
- sigaddset(&set, SIGUSR2);
- sigprocmask(SIG_BLOCK, &set, NULL);
-
- res = write(fds[1], "!", 1);
- assert(res == 1);
-
- siginfo_t info;
- res = sigwaitinfo(&set, &info);
- assert(res == SIGUSR2);
- assert(info.si_signo == SIGUSR2);
-
- res = write(fds[1], "!", 1);
- assert(res == 1);
-
- // XXX: This may not be long enough to get scheduled
- struct timespec tout = {1, 0};
- res = sigtimedwait(&set, &info, &tout);
- assert(res == SIGUSR2);
- assert(info.si_signo == SIGUSR2);
-
- res = write(fds[1], "!", 1);
- assert(res == 1);
-
- int sig;
- res = sigwait(&set, &sig);
- assert(res == 0);
- assert(sig == SIGUSR2);
-
- res = write(fds[1], "!", 1);
- assert(res == 1);
-
- res = sigtimedwait(&set, &info, &tout);
- assert(res < 0);
- assert(errno == EAGAIN);
-
- int wsts;
- res = waitpid(child, &wsts, 0);
- assert(res >= 0);
-}
-
-void child_fn() {
- int res;
- char c;
-
- res = read(fds[0], &c, 1);
- assert(res == 1);
- kill(parent, SIGUSR2);
- res = read(fds[0], &c, 1);
- assert(res == 1);
- kill(parent, SIGUSR2);
- res = read(fds[0], &c, 1);
- assert(res == 1);
- kill(parent, SIGUSR2);
- res = read(fds[0], &c, 1);
- assert(res == 1);
-}
-
-int main() {
- int res;
-
- parent = getpid();
- assert(parent > 0);
-
- res = pipe(fds);
- assert(res == 0);
-
- child = fork();
- assert(child >= 0);
- if (child)
- parent_fn();
- else
- child_fn();
-}