summaryrefslogtreecommitdiffstatshomepage
path: root/unix/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/file.c')
-rw-r--r--unix/file.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/unix/file.c b/unix/file.c
index 33acdccd06..a7620e079e 100644
--- a/unix/file.c
+++ b/unix/file.c
@@ -88,6 +88,14 @@ STATIC mp_uint_t fdfile_write(mp_obj_t o_in, const void *buf, mp_uint_t size, in
}
#endif
mp_int_t r = write(o->fd, buf, size);
+ while (r == -1 && errno == EINTR) {
+ if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) {
+ mp_obj_t obj = MP_STATE_VM(mp_pending_exception);
+ MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
+ nlr_raise(obj);
+ }
+ r = write(o->fd, buf, size);
+ }
if (r == -1) {
*errcode = errno;
return MP_STREAM_ERROR;
@@ -242,7 +250,7 @@ const mp_obj_type_t mp_type_fileio = {
.make_new = fdfile_make_new,
.getiter = mp_identity,
.iternext = mp_stream_unbuffered_iter,
- .stream_p = &fileio_stream_p,
+ .protocol = &fileio_stream_p,
.locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict,
};
#endif
@@ -261,7 +269,7 @@ const mp_obj_type_t mp_type_textio = {
.make_new = fdfile_make_new,
.getiter = mp_identity,
.iternext = mp_stream_unbuffered_iter,
- .stream_p = &textio_stream_p,
+ .protocol = &textio_stream_p,
.locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict,
};