From 6ba7d63e018c6d777c9fe7afdf9719fcb220c31a Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Tue, 25 Jan 2022 18:13:10 +0100 Subject: tools: kwboot: Handle EINTR in kwboot_write() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The write() syscall may be interrupted. Handle EINTR and retry it. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwboot.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tools') 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; } -- cgit v1.2.3