You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
input() is blocking exceptions at some phase during execution #112585
The following loop will soon stuck at some value, due to some phase of built-in input() itself is blocking exceptions and will not pass the exception to upper scope until an ENTER is hit on keyboard.
Unfortunately, the short answer is that using SIGINT like this is just inherently racy and unsafe. The main thread may receive it at any point after cnt[0] += 1. If that happens to be before the main thread calls fgets and blocks it will not be interrupted by the signal, and there we are.
Activity
TuringKi commentedon Dec 29, 2023
I have come up with a solution, but I am not sure if it is robust enough:
duaneg commentedon May 25, 2025
This is a very interesting test case.
Unfortunately, the short answer is that using
SIGINTlike this is just inherently racy and unsafe. The main thread may receive it at any point aftercnt[0] += 1. If that happens to be before the main thread callsfgetsand blocks it will not be interrupted by the signal, and there we are.