fix sleeping when receiving signals