This needs to be wrapped in the `retry` function to handle EINTR