If the interrupt signal is issued at the exact time that you are describing:
- flag checked false: loop input
- the signal is reset by setting the flag
1, but too late (test completed) - since the cycle has already been entered, it is called
pause(), and the program waits
, CTRL + C/SIGINT , , , .
, sleep:
while (sig_int_flag == 0)
{
printf("Hit CTRL+C in the next 10 seconds to trigger the bug\n");
sleep(10);
pause(); /* go to sleep, waiting for signal */
}
pause() :
while (sig_int_flag == 0)
{
sleep(1);
}
SIGINT , while sleep, , , , 1 , , , , , sleep , , , , pause , SIGINT.