From: Julien Ramseier <j.ramseier@gmail.com>
To: musl@lists.openwall.com
Subject: pthread_join stuck in infinite loop
Date: Sun, 20 Sep 2015 20:07:28 +0200 [thread overview]
Message-ID: <B9275837-6376-4749-8179-E203DC48E230@gmail.com> (raw)
[-- 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 --]
next reply other threads:[~2015-09-20 18:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-20 18:07 Julien Ramseier [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B9275837-6376-4749-8179-E203DC48E230@gmail.com \
--to=j.ramseier@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).