summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/lib/libpthread/process_kill/Makefile5
-rw-r--r--regress/lib/libpthread/process_kill/process_kill.c44
2 files changed, 49 insertions, 0 deletions
diff --git a/regress/lib/libpthread/process_kill/Makefile b/regress/lib/libpthread/process_kill/Makefile
new file mode 100644
index 00000000000..906b2f41b74
--- /dev/null
+++ b/regress/lib/libpthread/process_kill/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2012/03/07 22:01:29 fgsch Exp $
+
+PROG = process_kill
+
+.include <bsd.regress.mk>
diff --git a/regress/lib/libpthread/process_kill/process_kill.c b/regress/lib/libpthread/process_kill/process_kill.c
new file mode 100644
index 00000000000..51106362838
--- /dev/null
+++ b/regress/lib/libpthread/process_kill/process_kill.c
@@ -0,0 +1,44 @@
+/* $OpenBSD: process_kill.c,v 1.1 2012/03/07 22:01:29 fgsch Exp $ */
+/*
+ * Federico G. Schwindt <fgsch@openbsd.org>, 2012. Public Domain.
+ */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "test.h"
+
+void
+deadlock(int sig)
+{
+ PANIC("deadlock detected");
+}
+
+void
+handler(int sig)
+{
+
+}
+
+void *
+killer(void *arg)
+{
+ sleep(2);
+ CHECKe(kill(getpid(), SIGUSR1));
+ return (NULL);
+}
+
+int
+main(int argc, char **argv)
+{
+ pthread_t t;
+
+ ASSERT(signal(SIGALRM, deadlock) != SIG_ERR);
+ ASSERT(signal(SIGUSR1, handler) != SIG_ERR);
+ CHECKr(pthread_create(&t, NULL, killer, NULL));
+ alarm(5);
+ sleep(15);
+ CHECKr(pthread_join(t, NULL));
+ SUCCEED;
+}