mailing list of musl libc
 help / color / mirror / code / Atom feed
* pthread_join stuck in infinite loop
@ 2015-09-20 18:07 Julien Ramseier
  2015-09-20 18:29 ` Szabolcs Nagy
  2015-09-20 18:33 ` Rich Felker
  0 siblings, 2 replies; 5+ messages in thread
From: Julien Ramseier @ 2015-09-20 18:07 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]

Hello,

pthread_join() never returns when calling it on a detached thread.
I would expect it to return EINVAL instead.

Here’s a small test case:

#include <pthread.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>

void *world_thd(void *arg) {
	sleep(2);
	return NULL;
}

int main() {
	int ret;
	pthread_t thd;
	pthread_attr_t attr;

	if (pthread_attr_init(&attr))
		return 1;
	if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
		return 1;
	if (pthread_create(&thd, &attr, world_thd, NULL)) 
		return 1;

	ret = pthread_join(thd, NULL);
	if (ret == EINVAL)
		printf("Thread is not joinable\n");
	else {
		fprintf(stderr, "Failed to join thread: %i\n", ret);
		return 1;
	}

	return 0;
}


--
Julien


[-- Attachment #2: Type: text/html, Size: 4398 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-09-21  9:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-20 18:07 pthread_join stuck in infinite loop Julien Ramseier
2015-09-20 18:29 ` Szabolcs Nagy
2015-09-20 18:41   ` Jens Gustedt
2015-09-21  9:00     ` Julien Ramseier
2015-09-20 18:33 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).