Handle signals after pthread_cond_wait is interrupted

There might be signals that need to be run if pthread_cond_wait is
interrupted. Fixes #2093