1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:17:34 +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:
Sergey Bugaev 2020-09-10 16:40:32 +03:00 committed by Andreas Kling
parent 0055a28710
commit 039e529dbe

View file

@ -59,10 +59,9 @@ int main(int argc, char** argv)
printf("Sleep interrupted with %u seconds remaining.\n", remaining); 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); raise(SIGINT);
}
return 0; return 0;
} }