3ef05711ba5102a82c656a8a3ef8005cde9fd474
[platform/upstream/llvm.git] / clang-tools-extra / docs / clang-tidy / checks / bugprone-signal-handler.rst
1 .. title:: clang-tidy - bugprone-signal-handler
2
3 bugprone-signal-handler
4 =======================
5
6 Finds functions registered as signal handlers that call non asynchronous-safe
7 functions. Any function that cannot be determined to be an asynchronous-safe
8 function call is assumed to be non-asynchronous-safe by the checker,
9 including user functions for which only the declaration is visible.
10 User function calls with visible definition are checked recursively.
11 The check handles only C code. Only the function names are considered and the
12 fact that the function is a system-call, but no other restrictions on the
13 arguments passed to the functions (the ``signal`` call is allowed without
14 restrictions).
15
16 This check corresponds to the CERT C Coding Standard rule
17 `SIG30-C. Call only asynchronous-safe functions within signal handlers
18 <https://www.securecoding.cert.org/confluence/display/c/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers>`_
19 and has an alias name ``cert-sig30-c``.
20
21 .. option:: AsyncSafeFunctionSet
22
23   Selects which set of functions is considered as asynchronous-safe
24   (and therefore allowed in signal handlers). Value ``minimal`` selects
25   a minimal set that is defined in the CERT SIG30-C rule and includes functions
26   ``abort()``, ``_Exit()``, ``quick_exit()`` and ``signal()``. Value ``POSIX``
27   selects a larger set of functions that is listed in POSIX.1-2017 (see `this
28   link
29   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03>`_
30   for more information).
31   The function ``quick_exit`` is not included in the shown list. It is
32   assumable that  the reason is that the list was not updated for C11.
33   The checker includes ``quick_exit`` in the set of safe functions.
34   Functions registered as exit handlers are not checked.
35   
36   Default is ``POSIX``.
37