This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 20e1b633645616e51ab9609cee11b3e9c49cbd23 Author: ganjing <[email protected]> AuthorDate: Mon Nov 17 20:52:23 2025 +0800 libc/pthread: Use deferred cancellation in pthread_exit(). When a thread calls pthread_exit(), POSIX requires it to set its cancelability state to PTHREAD_CANCEL_DISABLE and its cancelability type to PTHREAD_CANCEL_DEFERRED. pthread_exit() only disabled cancellation, so a thread that had selected asynchronous cancellation kept it while its cleanup handlers and TLS destructors ran. Also set the cancelability type to deferred. Assisted-by: Kiro:auto Signed-off-by: ganjing <[email protected]> --- libs/libc/pthread/pthread_exit.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/libc/pthread/pthread_exit.c b/libs/libc/pthread/pthread_exit.c index c8008699316..2a0d9c7a736 100644 --- a/libs/libc/pthread/pthread_exit.c +++ b/libs/libc/pthread/pthread_exit.c @@ -64,6 +64,10 @@ void pthread_exit(FAR void *exit_value) task_setcancelstate(TASK_CANCEL_DISABLE, NULL); + /* Use deferred cancellation, as POSIX requires */ + + task_setcanceltype(TASK_CANCEL_DEFERRED, NULL); + tls_cleanup_popall(tls_get_info()); #if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
