On 1/25/22 18:13, Marek Behún wrote:
From: Pali Rohár <[email protected]>

The select() and read() syscalls may be interrupted. Handle EINTR and
retry them.

Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>

Reviewed-by: Stefan Roese <[email protected]>

Thanks,
Stefan


---
  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;

Viele Grüße,
Stefan Roese

--
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]

Reply via email to