mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:17:35 +00:00
Userland: Fix a signal race condition
It has been possible for a signal to arrive in between us checking g_interrupted and exiting - sucessfully, even though we were interrupted. This way, if a signal arrives before we reset the disposition, we will reliably check for it later; if it arrives afterwards, it'll kill us automatically.
This commit is contained in:
parent
0055a28710
commit
039e529dbe
1 changed files with 2 additions and 3 deletions
|
@ -59,10 +59,9 @@ int main(int argc, char** argv)
|
|||
printf("Sleep interrupted with %u seconds remaining.\n", remaining);
|
||||
}
|
||||
|
||||
if (g_interrupted) {
|
||||
signal(SIGINT, SIG_DFL);
|
||||
signal(SIGINT, SIG_DFL);
|
||||
if (g_interrupted)
|
||||
raise(SIGINT);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue