diff options
author | Pali Rohár <pali@kernel.org> | 2022-01-25 18:13:11 +0100 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2022-01-31 10:23:38 +0100 |
commit | 91fb095c0dc8390bee2442e7b635e2a93bb31c4a (patch) | |
tree | b8bac2f8222eb3aa96eb1845b648de4eae07ce9a /tools/kwboot.c | |
parent | 6ba7d63e018c6d777c9fe7afdf9719fcb220c31a (diff) | |
download | u-boot-91fb095c0dc8390bee2442e7b635e2a93bb31c4a.zip u-boot-91fb095c0dc8390bee2442e7b635e2a93bb31c4a.tar.gz u-boot-91fb095c0dc8390bee2442e7b635e2a93bb31c4a.tar.bz2 |
tools: kwboot: Handle EINTR in kwboot_tty_recv()
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>
Diffstat (limited to 'tools/kwboot.c')
-rw-r--r-- | tools/kwboot.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tools/kwboot.c b/tools/kwboot.c index 8b748f0..fca1c73 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; |