diff options
author | Ian Moffett <ian@osmora.org> | 2024-03-07 17:28:52 -0500 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-03-07 18:24:51 -0500 |
commit | f5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 (patch) | |
tree | 93b156621dc0303816b37f60ba88051b702d92f6 /lib/mlibc/tests/posix/sigsuspend.c | |
parent | bd5969fc876a10b18613302db7087ef3c40f18e1 (diff) |
build: Build mlibc + add distclean target
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/tests/posix/sigsuspend.c')
-rw-r--r-- | lib/mlibc/tests/posix/sigsuspend.c | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/lib/mlibc/tests/posix/sigsuspend.c b/lib/mlibc/tests/posix/sigsuspend.c deleted file mode 100644 index 09b9a1e..0000000 --- a/lib/mlibc/tests/posix/sigsuspend.c +++ /dev/null @@ -1,53 +0,0 @@ -#include <assert.h> -#include <unistd.h> -#include <pthread.h> -#include <signal.h> -#include <errno.h> - -_Atomic int handler_ready = 0; -_Atomic int thread_signal_ran = 0; - -static void sig_handler(int sig, siginfo_t *info, void *ctx) { - (void)sig; - (void)info; - (void)ctx; - - thread_signal_ran = 1; -} - -static void *worker(void *arg) { - (void)arg; - - struct sigaction sa; - sigemptyset(&sa.sa_mask); - sa.sa_sigaction = sig_handler; - sa.sa_flags = SA_SIGINFO; - assert(!sigaction(SIGUSR1, &sa, NULL)); - - handler_ready = 1; - - sigset_t set; - sigfillset(&set); - sigdelset(&set, SIGUSR1); - - assert(sigsuspend(&set)); - assert(thread_signal_ran); - assert(errno == EINTR); - - return NULL; -} - -int main() { - pthread_t thread; - assert(!pthread_create(&thread, NULL, &worker, NULL)); - - while (!handler_ready) - ; - - sleep(1); - - assert(!pthread_kill(thread, SIGUSR1)); - assert(!pthread_join(thread, NULL)); - - return 0; -} |