Hacker News new | ask | show | jobs
by ridiculous_fish 2585 days ago
What do you think about signal handlers?

Atomics may be implemented with locks, which makes them unsuitable for signal handlers. The only guaranteed lock-free type is `std::atomic_flag` which is not very useful.

`volatile sig_atomic_t` still seems like the better choice for signals.

2 comments

If the architecture is so broken that atomic load and stores need to use locks, I can't see how would sig_atomic_t would ever be implementable.
Indeed, "volatile sig_atomic_t" is the recommended official C way to change a flag from a signal handler.