Your expectation is wrong. Calling pthread_join
on a detached thread invokes undefined behavior. There is no requirement to set errno
, return the error code, or even return at all.
In case you need a citation,
The behavior is undefined if the value specified by the thread argument to pthread_join() does not refer to a joinable thread.
Source: http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_join.html
Also, note that most pthread functions, including pthread_join
, do not use errno
. Instead they return the error code as their return value. As such, inspecting errno
after calling a pthread function is wrong even if you didn't invoke undefined behavior when you called it.