From 91fb095c0dc8390bee2442e7b635e2a93bb31c4a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Tue, 25 Jan 2022 18:13:11 +0100 Subject: [PATCH] tools: kwboot: Handle EINTR in kwboot_tty_recv() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The select() and read() syscalls may be interrupted. Handle EINTR and retry them. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwboot.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index 8b748f0fdd..fca1c73c55 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -409,15 +409,19 @@ kwboot_tty_recv(int fd, void *buf, size_t len, int timeo) do { nfds = select(fd + 1, &rfds, NULL, NULL, &tv); - if (nfds < 0) + if (nfds < 0 && errno == EINTR) + continue; + else if (nfds < 0) goto out; - if (!nfds) { + else if (!nfds) { errno = ETIMEDOUT; goto out; } n = read(fd, buf, len); - if (n <= 0) + if (n < 0 && errno == EINTR) + continue; + else if (n <= 0) goto out; buf = (char *)buf + n; -- 2.39.5