diff options
| author | stijn <stijn@ignitron.net> | 2023-10-03 13:12:42 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-10-05 10:18:24 +1100 |
| commit | cac666f38cbce488a12c4fdcd28c2bb9d084368e (patch) | |
| tree | 102798f75dabdf43583e0a7af4d2db3bf7fab314 | |
| parent | 92717a95c048932e1085ff34ca799835515e442b (diff) | |
extmod/vfs_posix_file: Fix flush handling in msvc builds.
Flushing console output in msvc builds always fails because that
output is not buffered so don't propagate that as an error (in a
simlar way as was done in 1c047742 for macOS).
Signed-off-by: stijn <stijn@ignitron.net>
| -rw-r--r-- | extmod/vfs_posix_file.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/extmod/vfs_posix_file.c b/extmod/vfs_posix_file.c index 488593230..81a608d2b 100644 --- a/extmod/vfs_posix_file.c +++ b/extmod/vfs_posix_file.c @@ -153,11 +153,14 @@ STATIC mp_uint_t vfs_posix_file_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_ switch (request) { case MP_STREAM_FLUSH: { int ret; - // fsync(stdin/stdout/stderr) may fail with EINVAL (or ENOTSUP on macos), - // but don't propagate that error out. Because data is not buffered by - // us, and stdin/out/err.flush() should just be a no-op. - #ifdef __APPLE__ + // fsync(stdin/stdout/stderr) may fail with EINVAL (or ENOTSUP on macos or EBADF + // on windows), because the OS doesn't buffer these except for instance when they + // are redirected from/to file, but don't propagate that error out. Because data + // is not buffered by us, and stdin/out/err.flush() should just be a no-op. + #if defined(__APPLE__) #define VFS_POSIX_STREAM_STDIO_ERR_CATCH (err == EINVAL || err == ENOTSUP) + #elif defined(_MSC_VER) + #define VFS_POSIX_STREAM_STDIO_ERR_CATCH (err == EINVAL || err == EBADF) #else #define VFS_POSIX_STREAM_STDIO_ERR_CATCH (err == EINVAL) #endif |
