Thus an obvious way to handle signals is for signal handlers to set a global flag and have the event loop check for the flag immediately before and after the codice_2 call; if it is set, handle the signal in the same manner as with events on file descriptors. Unfortunately, this gives rise to a race condition: if a signal arrives immediately between checking the flag and calling codice_2, it will not be handled until codice_2 returns for some other reason (for example, being interrupted by a frustrated user).