summaryrefslogtreecommitdiff
path: root/libpthread/tests/test-2.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2012-02-19 05:50:33 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-02-19 05:50:33 +0100
commit6b2e5e0d91823c2a6ce5a5cb12ae3d00b82adae7 (patch)
tree30abf5fa5e54f2a079e53228083cf4d230efc102 /libpthread/tests/test-2.c
parent93ba48b6534f44c41f5739505dc9943d760a1867 (diff)
parentf115339ad63bfb0005bc3d1ebfb05e1a0aecc0db (diff)
Merge branch 'upstream-merged' of git.debian.org:/git/pkg-hurd/hurd into upstream-merged
Diffstat (limited to 'libpthread/tests/test-2.c')
-rw-r--r--libpthread/tests/test-2.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/libpthread/tests/test-2.c b/libpthread/tests/test-2.c
new file mode 100644
index 00000000..701462e8
--- /dev/null
+++ b/libpthread/tests/test-2.c
@@ -0,0 +1,39 @@
+/* Test detachability. */
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <assert.h>
+#include <error.h>
+#include <errno.h>
+#include <unistd.h>
+
+void *
+thread (void *arg)
+{
+ while (1)
+ sched_yield ();
+}
+
+int
+main (int argc, char **argv)
+{
+ int err;
+ pthread_t tid;
+ void *ret;
+
+ err = pthread_create (&tid, 0, thread, 0);
+ if (err)
+ error (1, err, "pthread_create");
+
+ err = pthread_detach (tid);
+ if (err)
+ error (1, err, "pthread_detach");
+
+ err = pthread_detach (tid);
+ assert (err == EINVAL);
+
+ err = pthread_join (tid, &ret);
+ assert (err == EINVAL);
+
+ return 0;
+}