Re: [PATCH] xread(): Fix read error when filtering >= 2GB on Mac OS X
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Aug 17, 2013, 18:57 UTC
- Message-ID
- <20130817185759.GA2904@elie.Belkin>
- In-Reply-To
- <1376743205-12618-1-git-send-email-prohaska@zib.de>
Hi,
Steffen Prohaska wrote:
Show 15 quoted lines
> --- a/wrapper.c
> +++ b/wrapper.c
> @@ -139,6 +139,14 @@ ssize_t xread(int fd, void *buf, size_t len)
> {
> ssize_t nr;
> while (1) {
> +#ifdef __APPLE__
> + const size_t twoGB = (1l << 31);
> + /* len >= 2GB immediately fails on Mac OS X with EINVAL when
> + * reading from pipe. */
> + if (len >= twoGB) {
> + len = twoGB - 1;
> + }
> +#endif
> nr = read(fd, buf, len);See 6c642a87 (compat: large write(2) fails on Mac OS X/XNU, 2013-05-10) for a cleaner way to do this.
Hope that helps, Jonathan