Re-work signal handling to use IO.select.