There is a limited number of functions that POSIX defines as async-signal safe
.
See here.
This includes some fundamental functions such as write
.
Since this is really a C
standard (since unix is built on C) that makes no mention of C++, I would expect this to be undefined, but the question is: can I use any c++ functions or classes (which involve constructors/destructors etc) inside a signal handler? For example: can I construct a std::string
or std::pair
?
malloc
is not on the list of async-signal safe functions, so it is probably safe to assume that the potential memory allocation used by std::string makes it async-signal unsafe in the general sense (?).