You shouldn't catch all the exceptions, just the ones derived from Exception. Otherwise this might catch a SIGINT when it's not supposed to.