]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: kwboot: Handle EINTR in kwboot_tty_recv()
authorPali Rohár <pali@kernel.org>
Tue, 25 Jan 2022 17:13:11 +0000 (18:13 +0100)
committerStefan Roese <sr@denx.de>
Mon, 31 Jan 2022 09:23:38 +0000 (10:23 +0100)
The select() and read() syscalls may be interrupted. Handle EINTR and
retry them.

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>
tools/kwboot.c

index 8b748f0fddf50763e10a87926cb41ed23fe3d9eb..fca1c73c5569b6c162cf19d610a0d073d841d7b3 100644 (file)
@@ -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;