1.. title:: clang-tidy - concurrency-thread-canceltype-asynchronous
2
3concurrency-thread-canceltype-asynchronous
4==========================================
5
6Finds ``pthread_setcanceltype`` function calls where a thread's cancellation
7type is set to asynchronous. Asynchronous cancellation type
8(``PTHREAD_CANCEL_ASYNCHRONOUS``) is generally unsafe, use type
9``PTHREAD_CANCEL_DEFERRED`` instead which is the default. Even with deferred
10cancellation, a cancellation point in an asynchronous signal handler may still
11be acted upon and the effect is as if it was an asynchronous cancellation.
12
13.. code-block:: c++
14
15  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
16
17This check corresponds to the CERT C Coding Standard rule
18`POS47-C. Do not use threads that can be canceled asynchronously
19<https://wiki.sei.cmu.edu/confluence/display/c/POS47-C.+Do+not+use+threads+that+can+be+canceled+asynchronously>`_.
20
21`cert-pos47-c` redirects here as an alias of this check.
22