Change sleep to be interrupt safe (otherwise the stack will kill it).