Nit picky, but this can just be `fd != -1`