Hi, We use full_read in Guile and just got a bug report that full_read was depending on the incoming errno. Eli Zaretskii proposed that the fix be like this:
> + errno = 0; > if (full_read (fd, cookie, sizeof cookie) != sizeof cookie [...] To recall, safe_read (called by full_read) looks like this: /* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if interrupted. Return the actual number of bytes read(written), zero for EOF, or SAFE_READ_ERROR(SAFE_WRITE_ERROR) upon error. */ size_t safe_rw (int fd, void const *buf, size_t count) { /* Work around a bug in Tru64 5.1. Attempting to read more than INT_MAX bytes fails with errno == EINVAL. See <http://lists.gnu.org/archive/html/bug-gnu-utils/2002-04/msg00010.html>. When decreasing COUNT, keep it block-aligned. */ enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 }; for (;;) { ssize_t result = rw (fd, buf, count); if (0 <= result) return result; else if (IS_EINTR (errno)) continue; else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count) count = BUGGY_READ_MAXIMUM; else return result; } } Here we see that if the system does not set errno on a partial read, as is apparently the case in MinGW, then we depend on the incoming value of errno. WDYT about having safe_rw set errno before entering the loop? Thanks, Andy -- http://wingolog.org/