summaryrefslogtreecommitdiffstatshomepage
path: root/unix
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-05-04 09:22:22 +0000
committerDamien George <damien.p.george@gmail.com>2016-06-28 11:28:49 +0100
commitf1b6db221875f6ad30ff0723f2c2302aeab70d0e (patch)
treeccebed18ab5a6845c8a35e7e1b5caf78eaf5b393 /unix
parente33806aaff5787d57bd708f99e565f1c490fc069 (diff)
downloadmicropython-f1b6db221875f6ad30ff0723f2c2302aeab70d0e.tar.gz
micropython-f1b6db221875f6ad30ff0723f2c2302aeab70d0e.zip
unix/file: If write syscall returns because of EINTR then try again.
As per PEP-475.
Diffstat (limited to 'unix')
-rw-r--r--unix/file.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/unix/file.c b/unix/file.c
index 7a23572e13..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;