Hi everyone,

Thanks to Andrew for adding me to this list.

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?

The RATIONALE section for pthread_cancel states that
        "If an implementation detects use of a thread ID after the end of
        its lifetime, it is recommended that the function should fail and
        report an [ESRCH] error."
but it's not immediately clear to me whether this is intended to mean
after the end of the lifetime of the *thread*, or the lifetime of the
*thread ID*.

FreeBSD recently changed from returning ESRCH in this case to returning
success:
https://lists.freebsd.org/pipermail/svn-src-head/2020-February/133736.html

but the ESRCH-returning behaviour is also present on Linux (CentOS 6/7 and
Debian testing):
http://mail.tarsnap.com/spiped/msg00183.html

-- 
Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid

Reply via email to