What will happen if I call pthread_join() on an unused pthread_t?
c, c++, pthreads
Solution
According to ISO C, the `newThread` variable is an "indeterminately valued object", the use of which triggers undefined behavior. It could have a "trap representation" which triggers a CPU exception.
Or it may just be interpreted as a random value of that type, which the API could handle in one of two ways: either there is no such thread, and `ESRCH` is returned, or by fluke there is such a thread. Then various cases arise: is it joinable or not, etc.
Problem
Suppose I have a declared pthread_t struct, like the following: ``` pthread_t newThread; ``` And then I call: ``` pthread_join(&newThread, NULL, myMethod, NULL); ``` What will pthread_join() do?