projects
/
oweals
/
busybox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d5b98e2
)
libbb: safe_write should not return EINTR
author
Denys Vlasenko
<vda.linux@googlemail.com>
Fri, 14 Jul 2017 12:22:09 +0000
(14:22 +0200)
committer
Denys Vlasenko
<vda.linux@googlemail.com>
Fri, 14 Jul 2017 12:22:09 +0000
(14:22 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/safe_write.c
patch
|
blob
|
history
diff --git
a/libbb/safe_write.c
b/libbb/safe_write.c
index 8f76280164adb69204290653ece5cff9dd5a1284..aad50f5e0244589f5d13e85b91e7cbdf3007b0fb 100644
(file)
--- a/
libbb/safe_write.c
+++ b/
libbb/safe_write.c
@@
-13,9
+13,17
@@
ssize_t FAST_FUNC safe_write(int fd, const void *buf, size_t count)
{
ssize_t n;
-
do
{
+
for (;;)
{
n = write(fd, buf, count);
- } while (n < 0 && errno == EINTR);
+ if (n >= 0 || errno != EINTR)
+ break;
+ /* Some callers set errno=0, are upset when they see EINTR.
+ * Returning EINTR is wrong since we retry write(),
+ * the "error" was transient.
+ */
+ errno = 0;
+ /* repeat the write() */
+ }
return n;
}