I would like to call pthread_join for a given thread id, but only if that thread has been started. The safe solution might be to add a variable to track which thread where s
I was porting some code that used pthreads into a C++ application, and I had the same question. I decided it was easier to switch to the C++ std::thread
object, which has the .joinable()
method to decide whether or not to join, i.e.
if (t.joinable()) t.join();
I found that just calling pthead_join
on a bad pthread_t value (as a result of pthread_create
failing) caused a seg fault, not just an error return value.