This pattern of the signal handler merely setting a global var seems robust. Of course, now the programmer must decide when and where to check the global value.
It must also be of an atomic type. POSIX specifies exactly one, namely “volatile sig_atomic_t”. I guess in C++11 etc. you can also use the language-provided atomics.