Fix write-region to null device on MS-Windows

* src/fileio.c (write_region) [WINDOWSNT]: Ignore EBADF errors
from fsync -- this means fsync is not supported for this file.
Happens, for example, with the null device.  (Bug#59545)
This commit is contained in:
Eli Zaretskii 2022-12-21 21:23:51 +02:00
parent f35da11199
commit ec9fbad908

View file

@ -5387,12 +5387,16 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
{ {
/* Transfer data and metadata to disk, retrying if interrupted. /* Transfer data and metadata to disk, retrying if interrupted.
fsync can report a write failure here, e.g., due to disk full fsync can report a write failure here, e.g., due to disk full
under NFS. But ignore EINVAL, which means fsync is not under NFS. But ignore EINVAL (and EBADF on Windows), which
supported on this file. */ means fsync is not supported on this file. */
while (fsync (desc) != 0) while (fsync (desc) != 0)
if (errno != EINTR) if (errno != EINTR)
{ {
if (errno != EINVAL) if (errno != EINVAL
#ifdef WINDOWSNT
&& errno != EBADF
#endif
)
ok = 0, save_errno = errno; ok = 0, save_errno = errno;
break; break;
} }