On Mon, Feb 24, 2020 at 3:32 PM Colin Percival <cperc...@tarsnap.com> wrote:
> I'm wondering if anyone has a clear answer for how pthread_cancel should > behave if called on a thread which has called pthread_exit (including an > implicit call by reaching the end of its start_routine) but has not yet > been the target of pthread_join. > > In particular, is it appropriate to return ESRCH in this case? > I don't think so, no. For joinable threads, the thread ID is valid until pthread_join() is called. Otherwise, pthread_join() would itself would be very difficult to use safely. Note that the same rationale text appears under pthread_join.