fix race condition in signals