handle EINTR when using read()/write()

This commit is contained in:
lieff 2017-04-06 17:40:52 +03:00
parent 10fe699466
commit 3d748b2250
1 changed files with 12 additions and 2 deletions

View File

@ -1956,7 +1956,12 @@ g_file_read(int fd, char *ptr, int len)
}
#else
return read(fd, ptr, len);
int readed;
do
{
readed = read(fd, ptr, len);
} while (readed == -1 && errno == EINTR);
return readed;
#endif
}
@ -1977,7 +1982,12 @@ g_file_write(int fd, const char *ptr, int len)
}
#else
return write(fd, ptr, len);
int written;
do
{
written = write(fd, ptr, len);
} while (written == -1 && errno == EINTR);
return written;
#endif
}