Question: Thread A executes a blocking call in a loop, until Thread B signals it to continue with the rest of the execution.

I tried the classic approach of an signal handler, which will change a condition variable, so I can test the condition before the the next call starts.

The problem now arises in the case, when the signal arrives after the check of the condition, but before the blocking call. 

Short pseudo code example of the problem:

```
while(!isInterrupted){
  raise(SIGINT)
  block()
}  

```

Assuming I cannot access or change the implementation of the blocking code and the blocking call doesn't provide an internal timeout functionality, which the signal handler could set to the minimal value, what would be the correct way for C and C++ to handle this?

Signals are used as the blocking call may only be woken up by receiving a SIGINT.

Thank you in advance for your help.

Answer: 
Stop using blocking calls, then switch to actual sychronisation primitives.
Please look at mutexes and condition variables for this.