diff options
author | 2001-08-15 14:37:10 +0000 | |
---|---|---|
committer | 2001-08-15 14:37:10 +0000 | |
commit | b2ea75c1b17e1a9a339660e7ed45cd24946b230e (patch) | |
tree | 07bfe557063f5ec0af38578d322f91f22d2299b8 /regress/lib/libpthread/signal/signal.c | |
parent | Same fix as for mvmeppc needed there, forgot this one. (diff) | |
download | wireguard-openbsd-b2ea75c1b17e1a9a339660e7ed45cd24946b230e.tar.xz wireguard-openbsd-b2ea75c1b17e1a9a339660e7ed45cd24946b230e.zip |
Regression tests for libc_r (pthreads) library.
Thanks to pval@ for resolving the license stuff.
Diffstat (limited to 'regress/lib/libpthread/signal/signal.c')
-rw-r--r-- | regress/lib/libpthread/signal/signal.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/regress/lib/libpthread/signal/signal.c b/regress/lib/libpthread/signal/signal.c new file mode 100644 index 00000000000..8e428e0962c --- /dev/null +++ b/regress/lib/libpthread/signal/signal.c @@ -0,0 +1,49 @@ +/* $OpenBSD: signal.c,v 1.1.1.1 2001/08/15 14:37:13 fgsch Exp $ */ +/* David Leonard <d@openbsd.org>, 2001. Public Domain. */ + +/* + * This program tests signal handler re-entrancy. + */ + +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <signal.h> +#include "test.h" + +void * +sleeper(arg) + void *arg; +{ + sigset_t mask; + + /* Ignore all signals in this thread */ + sigfillset(&mask); + CHECKe(sigprocmask(SIG_SETMASK, &mask, NULL)); + + ASSERT(sleep(2) == 0); + SUCCEED; +} + +void +handler(sig) + int sig; +{ + printf("signal handler %d\n", sig); + alarm(1); + signal(SIGALRM, handler); +} + +int +main() +{ + pthread_t slpr; + + ASSERT(signal(SIGALRM, handler) != SIG_ERR); + CHECKe(alarm(1)); + CHECKr(pthread_create(&slpr, NULL, sleeper, NULL)); + /* ASSERT(sleep(1) == 0); */ + for (;;) + CHECKe(write(STDOUT_FILENO, ".", 1)); +} |