* SUCH DAMAGE.
*
* $FreeBSD: src/lib/libc_r/uthread/uthread_join.c,v 1.12.2.8 2002/10/22 14:44:03 fjoe Exp $
- * $DragonFly: src/lib/libc_r/uthread/uthread_join.c,v 1.3 2005/05/30 20:50:53 joerg Exp $
*/
#include <errno.h>
#include <pthread.h>
}
/* Check if the thread was not found or has been detached: */
- if (thread == NULL ||
- ((pthread->attr.flags & PTHREAD_DETACHED) != 0)) {
+ if (thread == NULL) {
/* Undefer and handle pending signals, yielding if necessary: */
_thread_kern_sig_undefer();
- /* Return an error: */
+ /* Thread not found. */
ret = ESRCH;
+ } else if ((pthread->attr.flags & PTHREAD_DETACHED) != 0) {
+ /* Undefer and handle pending signals, yielding if necessary: */
+ _thread_kern_sig_undefer();
+
+ /* Thread is in detached state. */
+ ret = EINVAL;
+
} else if (pthread->joiner != NULL) {
/* Undefer and handle pending signals, yielding if necessary: */
_thread_kern_sig_undefer();
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $DragonFly: src/lib/libthread_xu/thread/thr_join.c,v 1.7 2006/04/06 13:03:09 davidxu Exp $
*/
#include "namespace.h"
if ((ret = _thr_find_thread(curthread, pthread, 1)) != 0) {
ret = ESRCH;
} else if ((pthread->tlflags & TLFLAGS_DETACHED) != 0) {
- ret = ESRCH;
+ ret = EINVAL;
} else if (pthread->joiner != NULL) {
/* Multiple joiners are not supported. */
ret = ENOTSUP;