HomeFreeBSD

pthread_setcancelstate(3): make it async-signal-safe

Description

pthread_setcancelstate(3): make it async-signal-safe

by setting new cancel state and reading old cancel state from the
curthread structure atomic.

Note that this does not play well with async cancellation, since if
cancellation is enabled from a signal handler and cancellation request
is pending, the thread is cancelled immediately, calling user-defined
destructors, which all must be async-signal-safe (but this is a general
requirement for async cancellation anyway).

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D48200

Details

Provenance
kibAuthored on Dec 23 2024, 6:42 AM
Reviewer
markj
Differential Revision
D48200: Several fixes for libthr, related to cancellation
Parents
rGa944e6d5c0c2: thr_cancel.c: use testcancel() instead of manually expanding it
Branches
Unknown
Tags
Unknown