| 1 |
.. title:: clang-tidy - concurrency-thread-canceltype-asynchronous |
| 2 |
|
| 3 |
concurrency-thread-canceltype-asynchronous |
| 4 |
========================================== |
| 5 |
|
| 6 |
Finds ``pthread_setcanceltype`` function calls where a thread's cancellation |
| 7 |
type 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 |
| 10 |
cancellation, a cancellation point in an asynchronous signal handler may still |
| 11 |
be 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 |
|
| 17 |
This 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. |