diff --git a/tests/Makefile b/tests/Makefile index 948215e198..acc7d5de3b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -204,6 +204,7 @@ NAMES=\ unistd/sysconf \ pthread/main \ pthread/cleanup \ + pthread/exit \ pthread/extjoin \ pthread/once \ pthread/customstack \ diff --git a/tests/pthread/exit.c b/tests/pthread/exit.c new file mode 100644 index 0000000000..35fc31cf21 --- /dev/null +++ b/tests/pthread/exit.c @@ -0,0 +1,31 @@ +#include +#include +#include + +#include + +#include "common.h" + +void *routine(void *arg) { + assert(arg == NULL); + + sleep(1); + + puts("Thread "); + + return NULL; +} + +int main(void) { + int status; + pthread_t thread; + + if ((status = pthread_create(&thread, NULL, routine, NULL)) != 0) { + return fail(status, "failed to create thread"); + } + if ((status = pthread_detach(thread)) != 0) { + return fail(status, "failed to detach thread"); + } + + pthread_exit(NULL); +}