Mostly doc, plus close(fd) on error.