...
Many systems define an implementation-specific list of asynchronous safe functions. In general, I/O functions are not safe to invoke inside signal handlers. Check your system's asynchronous-safe functions before using them in signal handlers.
...
Noncompliant Code Example
In this non-compliant noncompliant code example, the program allocates a string on the heap, and uses it to log messages in a loop. The program also registers the signal handler int_handler()
to handle the terminal interrupt signal SIGINT
. The int_handler()
function logs the last message, calls free()
, and exits.
...