unsafe fileserver.c example (about Unix signals)
Opened this issue · 0 comments
bstarynk commented
In commit 2b3b230 the fileserver.c
example has unsafe code about signal (near line 154, calling signal(2) ...)
Read both signal(7) and signal-safety(7).
We might take inspiration from Qt5 Unix signal handling, that is use the famous pipe(7) to self trick. Then all the event loops should also poll(2) on that pipe (reading end) and the signal handler would write(2) at least a byte on that pipe (writing end).
We could also decide to declare some extern volatile sigatomic_t onion_should_stop;
variable and have signal handlers setting onion_should_stop
and have all the event loops testing that variable repeatedly.