summaryrefslogtreecommitdiff
path: root/regress/lib/libc_r/signal
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2001-08-15 14:37:17 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2001-08-15 14:37:17 +0000
commitee29ce09990030fd5a7c6f78dde0dabfab952171 (patch)
treedc17f6ce9d5ba480f50f3c02569aa0737499684c /regress/lib/libc_r/signal
parent344dc84d0dc63d3256aca03797112a766d32f738 (diff)
Regression tests for libc_r (pthreads) library.
Thanks to pval@ for resolving the license stuff.
Diffstat (limited to 'regress/lib/libc_r/signal')
-rw-r--r--regress/lib/libc_r/signal/Makefile6
-rw-r--r--regress/lib/libc_r/signal/signal.c49
2 files changed, 55 insertions, 0 deletions
diff --git a/regress/lib/libc_r/signal/Makefile b/regress/lib/libc_r/signal/Makefile
new file mode 100644
index 00000000000..b107b790354
--- /dev/null
+++ b/regress/lib/libc_r/signal/Makefile
@@ -0,0 +1,6 @@
+# $OpenBSD: Makefile,v 1.1 2001/08/15 14:37:13 fgsch Exp $
+
+PROG= signal
+SRCS= signal.c
+
+.include <bsd.prog.mk>
diff --git a/regress/lib/libc_r/signal/signal.c b/regress/lib/libc_r/signal/signal.c
new file mode 100644
index 00000000000..effc36b7087
--- /dev/null
+++ b/regress/lib/libc_r/signal/signal.c
@@ -0,0 +1,49 @@
+/* $OpenBSD: signal.c,v 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));
+}