Signal Handlers - Possible Solution: Flag we still have an issue the compiler can reorder reads and writes, even to your sig_atomic_t flag, and we're in the same locking issues again. for once, there is an easy solution: the volatile keyword.