For some reason I thought that calling pthread_exit(NULL)
at the end of a main function would guarantee that all running threads (at least created in the main funct
Quite aside from whether the program should or should not terminate when the main thread calls pthread_exit
, pthread_exit
says
The pthread_exit() function terminates the calling thread
And also:
After a thread has terminated, the result of access to local (auto) variables of the thread is undefined.
Since the context is an automatic variable of main()
, your code can fall over before it even gets to the point of testing what you want it to test...