summaryrefslogtreecommitdiff
path: root/ports/unix/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/unix/file.c')
-rw-r--r--ports/unix/file.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ports/unix/file.c b/ports/unix/file.c
index 0fe4f9878..ed05fe733 100644
--- a/ports/unix/file.c
+++ b/ports/unix/file.c
@@ -126,6 +126,13 @@ STATIC mp_uint_t fdfile_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, i
int ret = fsync(o->fd);
MP_THREAD_GIL_ENTER();
if (ret == -1) {
+ if (errno == EINVAL
+ && (o->fd == STDIN_FILENO || o->fd == STDOUT_FILENO || o->fd == STDERR_FILENO)) {
+ // fsync(stdin/stdout/stderr) may fail with EINVAL, 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.
+ return 0;
+ }
*errcode = errno;
return MP_STREAM_ERROR;
}