Retry wait() on EINTR; clean up signal handling