diff options
author | Neal H. Walfield <neal@gnu.org> | 2002-10-10 23:05:06 +0000 |
---|---|---|
committer | Neal H. Walfield <neal@gnu.org> | 2002-10-10 23:05:06 +0000 |
commit | 51c55d85632d43aa362b625ae519d00d559f9e5c (patch) | |
tree | 2efb73388ae81c46c1475bcb3133b879a0176bf1 /tests/test-2.c |
Import libpthread.
Diffstat (limited to 'tests/test-2.c')
-rw-r--r-- | tests/test-2.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test-2.c b/tests/test-2.c new file mode 100644 index 0000000..701462e --- /dev/null +++ b/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; +} |