Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsafe fileserver.c example (about Unix signals) #278

Open
bstarynk opened this issue Nov 21, 2020 · 0 comments
Open

unsafe fileserver.c example (about Unix signals) #278

bstarynk opened this issue Nov 21, 2020 · 0 comments

Comments

@bstarynk
Copy link
Contributor

bstarynk commented Nov 21, 2020

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.

@bstarynk bstarynk changed the title unsafe fileserver.c example unsafe fileserver.c example (about Unix signals) Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant