Fix deadlock issue in signal handling of sleeping threads