Skip to content
Snippets Groups Projects
Commit f1b6db22 authored by Damien George's avatar Damien George
Browse files

unix/file: If write syscall returns because of EINTR then try again.

As per PEP-475.
parent e33806aa
Branches
No related tags found
No related merge requests found
...@@ -88,6 +88,14 @@ STATIC mp_uint_t fdfile_write(mp_obj_t o_in, const void *buf, mp_uint_t size, in ...@@ -88,6 +88,14 @@ STATIC mp_uint_t fdfile_write(mp_obj_t o_in, const void *buf, mp_uint_t size, in
} }
#endif #endif
mp_int_t r = write(o->fd, buf, size); 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) { if (r == -1) {
*errcode = errno; *errcode = errno;
return MP_STREAM_ERROR; return MP_STREAM_ERROR;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment