From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B16A3C433FE for ; Tue, 25 Jan 2022 17:15:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8C2F6838C8; Tue, 25 Jan 2022 18:14:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="b4JFLNkd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 461A9830D0; Tue, 25 Jan 2022 18:13:43 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 37BCC838A6 for ; Tue, 25 Jan 2022 18:13:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DC9B4B819AB; Tue, 25 Jan 2022 17:13:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94A58C36AE9; Tue, 25 Jan 2022 17:13:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643130815; bh=7Ie8D2/vV7KRrpwUQBNGBacpIP9uIx69AdrsD6FD7a4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b4JFLNkd1s2Xit/FEHDNmmj3ZlbCOsrj8N72eggEkVPb9xKLTnHHzOyv/kRDBwnh7 5bVa7M7vW0e/3X7U2b+IxXf8vndwZL3NeWq+AHfOszPtCUv+U8Ikji3AUbL/c1RYuG uEmVxUyiHdtA3bhKSy4ZRykfr+V2ynK96A+29ygJ+L+FRF8rbS+bphCe7qPG/p9rfj vzzcY41tH7mmjzv5rmsgTwVCjiD//pGCHYzYVyA0bavkvYxW7YVGDBZaq8Xs4ELRIN tnv3PpogQjYFZCez6/3TPaTnNC4D+pUZJxHlLYK2mER/ZMqdMtFAkURt4GUiPaNp7C Wg4LLKn/Pexhw== From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: Stefan Roese Cc: u-boot@lists.denx.de, pali@kernel.org, =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH u-boot-marvell 12/14] tools: kwboot: Handle EINTR in kwboot_tty_recv() Date: Tue, 25 Jan 2022 18:13:11 +0100 Message-Id: <20220125171313.14498-13-kabel@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125171313.14498-1-kabel@kernel.org> References: <20220125171313.14498-1-kabel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár 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 --- 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.34.1