I\'m wondering if it is safe to call pthread_cancel()
on a terminated thread. I couldn\'t find any hints in the manual page. Thanks in advance for any hints.
I think it needs to be safe, or pthread_cancel
would be problematic (next to unusable).
Indeed, if it wouldn't be safe, every call to pthread_cancel
would have to be enormously complicated by checking the thread is alive (and ensuring it stays alive until you get to cancel it). A simple "are you still there" wouldn't do.
In conclusion, I believe pthread_cancel
must be safe if the thread has terminated. Of course, this might not be the case for a terminated and joined thread.