projects
/
libjh.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3aef24f
)
io: retry read/write on EINTR
author
Jann Horn
<jann@thejh.net>
Mon, 19 Aug 2013 21:15:29 +0000
(23:15 +0200)
committer
Jann Horn
<jann@thejh.net>
Mon, 19 Aug 2013 21:15:29 +0000
(23:15 +0200)
io.c
patch
|
blob
|
history
diff --git
a/io.c
b/io.c
index
3c0a8eb
..
2173478
100644
(file)
--- a/
io.c
+++ b/
io.c
@@
-24,6
+24,7
@@
PUBLIC_FN ssize_t read_nointr(int fd, void *buf, size_t count, int *last_res) {
size_t done = 0;
while (done < count) {
ssize_t part_res = read(fd, buf+done, count-done);
size_t done = 0;
while (done < count) {
ssize_t part_res = read(fd, buf+done, count-done);
+ if (part_res == -1 && errno == EINTR) continue;
if (part_res <= 0) {
if (last_res) *last_res = part_res;
if (done) return done;
if (part_res <= 0) {
if (last_res) *last_res = part_res;
if (done) return done;
@@
-47,6
+48,7
@@
PUBLIC_FN ssize_t write_nointr(int fd, void *buf, size_t count, int *last_res) {
size_t done = 0;
while (done < count) {
ssize_t part_res = write(fd, buf+done, count-done);
size_t done = 0;
while (done < count) {
ssize_t part_res = write(fd, buf+done, count-done);
+ if (part_res == -1 && errno == EINTR) continue;
if (part_res <= 0) {
if (last_res) *last_res = part_res;
if (done) return done;
if (part_res <= 0) {
if (last_res) *last_res = part_res;
if (done) return done;