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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With