Backporting signal handling while "sleeping" from #352
Merge pull request #353 from meatballhat/backport-handle-signals-in-sleep-loop

Backporting signal handling while "sleeping" from #352