Y
Hacker News
new
|
ask
|
show
|
jobs
by
fanf2
719 days ago
Exactly, yes :-) Signal handlers have so many hazards it's vital to keep them as simple as possible.
3 comments
rwmj
719 days ago
A rule I try to follow: either set a global variable or write to a self pipe (using the write syscall), and handle the signal in the main loop.
link
cesarb
718 days ago
> either set a global variable
IIRC, the rule is also that said global variable must have the type "volatile sig_atomic_t".
link
lokar
718 days ago
You should read the sigsev handler at google, it’s great, doing all kinds of things. Of course it’s going to crash at some point anyway….
link
growse
719 days ago
I'm not overly familiar with the language and tooling ecosystem, but how trivial is this to detect on a static analysis?
link
kccqzy
718 days ago
Quite easy.
link