summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2022-01-25 20:13:10 +0300
committerStefan Roese <sr@denx.de>2022-01-31 12:23:38 +0300
commit6ba7d63e018c6d777c9fe7afdf9719fcb220c31a (patch)
tree3d96005f0ba41e974b2027b5d0e49f389135916e /tools
parent8d3b79c4a391892f270473cfc3117d45ffe05008 (diff)
downloadu-boot-6ba7d63e018c6d777c9fe7afdf9719fcb220c31a.tar.xz
tools: kwboot: Handle EINTR in kwboot_write()
The write() syscall may be interrupted. Handle EINTR and retry it. Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'tools')
-rw-r--r--tools/kwboot.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/kwboot.c b/tools/kwboot.c
index de433c1b04..8b748f0fdd 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -292,13 +292,15 @@ static int blk_rsp_timeo = KWBOOT_BLK_RSP_TIMEO;
static ssize_t
kwboot_write(int fd, const char *buf, size_t len)
{
- size_t tot = 0;
+ ssize_t tot = 0;
while (tot < len) {
ssize_t wr = write(fd, buf + tot, len - tot);
- if (wr < 0)
- return -1;
+ if (wr < 0 && errno == EINTR)
+ continue;
+ else if (wr < 0)
+ return wr;
tot += wr;
}