From patchwork Fri Apr 22 23:59:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1621282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=NLU1JfZf; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::c3b; helo=mail-oo1-xc3b.google.com; envelope-from=swupdate+bncbcwivbv7sugrb7mcrwjqmgqee4usozq@googlegroups.com; receiver=) Received: from mail-oo1-xc3b.google.com (mail-oo1-xc3b.google.com [IPv6:2607:f8b0:4864:20::c3b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KlWcK2Rqtz9s0r for ; Sat, 23 Apr 2022 10:00:00 +1000 (AEST) Received: by mail-oo1-xc3b.google.com with SMTP id z4-20020a4a9c84000000b00329c324ddb7sf4652533ooj.22 for ; Fri, 22 Apr 2022 16:59:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1650671997; cv=pass; d=google.com; s=arc-20160816; b=rS4ZfQxtuHwMEaWWi+wZREy51r+SHwMPrgcyIe7n1USJQHZKSwBWl8efkm2su7tkCM 0pXG9+jXsjtKoMwopMV98ntdBz9FenjGEycnFI9BSfmjbT9o57houYBW5yGd+HLVBUqJ heEwSSdSAfFPaQsNyZMIFpdDvtjgXduhfzipS9/PNc3d1CXlcHdgSALhv43qbJMYqabq cZV2V2TD3V3/tmIfijBIWqV0rXERcN1XhBPPpeYZyS1HFpiOEw6ea/IbqRvqCVZmJu9t gcBaMGLrvAexIoSaeI6ICaOntem0yuZDGZXCUt+nXziE6RhqZHBVYKi9A2A1whW7Z3Ng vlUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=63oK6v5f+y1CoG7+RQ7HsdxwORbay8S5BwHDx/fGdyY=; b=fRto7JR49tBzif1uGag5R/7peziLmFeRnhnUsHSwT/ipfcXkWPGUg6PA7IF6jOQDZv EBnN9vZKBtjY0c8sJh0O/tXrPaLjHtiH+WbqYjnCe0ZZUkWZCjj6mP9qtEU0DkFV//KH nyyvRvuKoJ7pdYQPR0lSvY4lskJ+Qjkn8XLvHX/357TCxcyo2ulmaGmP67FQmSFxh05b Q+TjEiX6Uvl5aYgb5ncExThx6rjYLQz3eh2sOi/vcYHlawZzmwcgDEv8sLDV+PaAr/dG wtk7MZIoZQwmqs4Av/FsguN3DbnHk5y4AzCToCMgFBuwI+3mH7a8/4akHMXm1kco7TRZ mxrw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=63oK6v5f+y1CoG7+RQ7HsdxwORbay8S5BwHDx/fGdyY=; b=NLU1JfZfjSqkIDsi7/Nau2WJjv7yPwWASaesKn3f6FLFiL1dKnCoe+6DEKwvtyS8qp R1uZQBK7FcfSJboIxW9qIXgJ0oh6FVLEAS8hawXqr8J9nHz9KDIMv/fI1OK/2AJl/esO MB/aqqLKby7t5drAm73pwtLNj/5nJhkInTJrmkQJkqr9M5A8eWbf7X0HR39jtXczaR/l VkFjXw9eP4BZzBRNBnXZSyRLxPD+nt5ZL6++zY4OhtPZszYE5924pIRWfy8grcEG4V86 rCF+5W4pzanw+MAnZrTCZzRyiOHENTpCsvLd/eKJG3eaO7s6FZXSkd/LrZ7K+DdpEc8Y JXNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=63oK6v5f+y1CoG7+RQ7HsdxwORbay8S5BwHDx/fGdyY=; b=d1+qw8Fe+7U+omqMEd6nq7u7E98AMwe3ZvVuXwsvVVKfic5NfP/YkKVAG/8t1PCcBs X42oBxYOjkryARdNu6D11mJshnBaHTG5Neh4uH8WJXcNjbZaOBD/SPKERNQVhiymywnU uhEuMNZTJvJ7wgsAWnprUyXDT99/rD8+EdkJQuv5Wfd+SgXz+MErMsgfGFwdfkN6w/Nc g9i+Cc7E7ezkNo4di8jm4mbNaGgMCQOzxrEkpYPusZHnJw9wKiDxKpOHku9766AtcAKR nCpZcBCMs2WMi6k5r1UkWi57hLBGBYDJ8tuFSATXvJRf0uf7khvsVLg51tn9dotck2RC hotQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532IcNcpNDpB4qvhdZK2IqxWyOH6ZzH+xVgkjjwDaKzv+/UR5S46 MqdV/I14QwK769ZZnfp6Qxc= X-Google-Smtp-Source: ABdhPJwXZTe/V15qySftwf4AgjiIsnXkJ5WeWQmOwyXXGklWmkQcytUob097FtyQyZlHHxlluG8V5w== X-Received: by 2002:a05:6830:1388:b0:604:cd7d:6b74 with SMTP id d8-20020a056830138800b00604cd7d6b74mr2695639otq.290.1650671997475; Fri, 22 Apr 2022 16:59:57 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6830:181:b0:601:cc83:6913 with SMTP id q1-20020a056830018100b00601cc836913ls474273ota.0.gmail; Fri, 22 Apr 2022 16:59:57 -0700 (PDT) X-Received: by 2002:a9d:12a8:0:b0:605:52fb:5f26 with SMTP id g37-20020a9d12a8000000b0060552fb5f26mr2692476otg.297.1650671997061; Fri, 22 Apr 2022 16:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650671997; cv=none; d=google.com; s=arc-20160816; b=Qi/2OkRiawzTLUGDRY2Ke6IEFZbHacYEvDwkU3N08RPAaHUBpk5l37DVeeiPZARh7a yyh4SD2az5wEwX0z4Oa28ltHEEMNuwVI8ehLw5rIit4FvW2XpNzvHCe3r5ru3OJ6vLBd FPlCkKlyMsgGie6nUhgfrxHnrpAEO63i3/c9n6O+k6AvnpCiu9s7Y1j4c+b/b4me1qPv vYUE6MipdRlvNggtvsIwSi4a97vatZ00f6l1f3PdAax0h3DBNXf7moKpyN3QnzbiSbn8 ZGMhnayNkcm170tWxhH9ftcCFhi1RIIYoiXQRCH+LnIVvjw9SdHrRSdAWVWfC1SZah97 kAHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=/W5gCYun8b+mq0v/2p0Cackc29FbG98dJQNDuau7Vzk=; b=gqXh+poDR8ZHg6NVhzaTWHAsI6QdUU2CDqSAuuoQI56c2pCNUaQSdO4GRUJE1RcBHl d+/Xhn370gy8RVpWHhh2ZuOk9h9cLh5sB3RwKvgXLsF1tP2fZmyeEsSMbkJYpfl8Z6zg L+kWeCZ0vhJ3udJMGx28+BBxOscU0W6/UF3DGUKvEYgkqZkqln/JB659zeFIjBS1Uxxp RAx/JJj/VM65OMVWLfyIc4FefjDr3/fScYLLEFgRCXmjj8uijZt+pk7knR5UtL7e6OhQ /fpCN0wDN4C6/nEwAUQ7P/OGMu3Ib30iuYpfqpmEa53LA4XilxZCElFN/PODtXra2PqB QQuw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTP id be15-20020a056808218f00b003227a4ecc4asi1264921oib.3.2022.04.22.16.59.56 for ; Fri, 22 Apr 2022 16:59:56 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id 240FD20D69 for ; Sat, 23 Apr 2022 08:59:55 +0900 (JST) Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 0694820D66 for ; Sat, 23 Apr 2022 08:59:55 +0900 (JST) Received: by mail-pl1-f197.google.com with SMTP id q6-20020a170902eb8600b001588e49dcaaso5580058plg.9 for ; Fri, 22 Apr 2022 16:59:54 -0700 (PDT) X-Received: by 2002:a17:90a:e7cb:b0:1d2:194d:8744 with SMTP id kb11-20020a17090ae7cb00b001d2194d8744mr19057034pjb.71.1650671994041; Fri, 22 Apr 2022 16:59:54 -0700 (PDT) X-Received: by 2002:a17:90a:e7cb:b0:1d2:194d:8744 with SMTP id kb11-20020a17090ae7cb00b001d2194d8744mr19057019pjb.71.1650671993827; Fri, 22 Apr 2022 16:59:53 -0700 (PDT) Received: from pc-0115 (126.88.200.35.bc.googleusercontent.com. [35.200.88.126]) by smtp.gmail.com with ESMTPSA id p27-20020a056a000a1b00b004f3f63e3cf2sm4295500pfh.58.2022.04.22.16.59.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2022 16:59:51 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.95) (envelope-from ) id 1ni3Bm-00BmZE-5h; Sat, 23 Apr 2022 08:59:50 +0900 From: Dominique Martinet To: swupdate@googlegroups.com, sbabic@denx.de Cc: Dominique Martinet Subject: [swupdate] [PATCH 1/6] sigchld_handler: report child exit status correctly Date: Sat, 23 Apr 2022 08:59:39 +0900 Message-Id: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Dominique Martinet --- core/pctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/pctl.c b/core/pctl.c index 2a09d9807e3a..ed5d49bbbf01 100644 --- a/core/pctl.c +++ b/core/pctl.c @@ -429,7 +429,7 @@ void sigchld_handler (int __attribute__ ((__unused__)) signum) hasdied = 0; if (WIFEXITED(status)) { hasdied = 1; - printf("exited, status=%d\n", WIFEXITED(status)); + printf("exited, status=%d\n", WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { hasdied = 1; printf("killed by signal %d\n", WTERMSIG(status)); From patchwork Fri Apr 22 23:59:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1621285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=NbIsZSN3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::c3e; helo=mail-oo1-xc3e.google.com; envelope-from=swupdate+bncbcwivbv7sugrb7mcrwjqmgqee4usozq@googlegroups.com; receiver=) Received: from mail-oo1-xc3e.google.com (mail-oo1-xc3e.google.com [IPv6:2607:f8b0:4864:20::c3e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KlWcK2ttZz9s5V for ; Sat, 23 Apr 2022 10:00:00 +1000 (AEST) Received: by mail-oo1-xc3e.google.com with SMTP id z5-20020a4a8705000000b00324936534b6sf4689024ooh.9 for ; Fri, 22 Apr 2022 16:59:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1650671997; cv=pass; d=google.com; s=arc-20160816; b=cwmYnLRTBYIXkfPUr8aJS0PTXtlLxpOoPxcPA+g4Lx3nTFC3gSRwRFI7bl6k8q4Jqf 3962lOhX9wh2yvOPovRy0MJNd5DDxYgLt0Xt35RlA9T73wXUWU+QOO1aMhvy3WTXuRt5 uk7bMfWK+lcdgfPWHzXJQ3LNsrWsXAN022LPSV/MFzN3GHn9bMFXBejbnpBYy7bz97PS WKYoiAytsJNn/1hamIlsIbiZUK9lEz6aSftScI9P+LqJNFJLNQWws++0f5UWY0UweAcO AFn6fNrJaS+JJn51e8oBitlYTZuJD6jfuDhfwhnAfyCnPO3eQT3PyWRrij9GXZVovG/2 fowQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=FmLn1We4G4Wc3+AAT8RwU8DweP1AVqFc7zVXZuCzZmo=; b=Izeh7eiTiSLg/sqxM9gMr0QKlOe2p0h9j4tbU1a8FYdtXPTBEepv5zEHY3v5VgUbv5 gz5d8YKqSOwLQnLrnX1pAygb9yVd7twYcYzI86mPKmWOdpQkpuW3ZtXn0RW38cm9peFN GBj4kMb5gq5dTqPFvzYotzzGH3smMmJ5ZsCkZsNrUxDPsk5z1E/9iskthSCJeA2FetmM RLcrVpx1YcdFF57K0q16yTrF9sZYDgaYURWZ8dbXN0g9N8IwhydgwbfGVTQsgZn1+0fu rggZa8198fmrEgt+P1Ia5q++r5NWGETvIATcEbGkzSuSkrskb8EZY4pLxSUx1S7aWDFv /60g== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=FmLn1We4G4Wc3+AAT8RwU8DweP1AVqFc7zVXZuCzZmo=; b=NbIsZSN3ZMu8MrqxNgiZhqqF9XLhJ4izPSu/Z/kBaoUcTsnC4IiHn2U+CrvlqDiQ9D VyIUsfP7FV6C1ZI7EkUDvZ8YyWu+LNMQQ0JYoGAiCElp+dbFGuVo/4847593F+TdwBrj zIaVBfEhI/u3LGvggZCsba6dn+krwnL6gkvweueOa0ZqmUvRVYCSlQ4HuTSKqsxAtmRr YqYQPx7PnIwF+WPXcvoh26I6Nl8j4eMkSdobA7GDm+dYDVTp7dg1y5ss9oKklBT4nHM7 XFYXoR/gEk6HyHxiaWgLIWjc66PXpnkD9PUxLg896zD1iDEyyrw7a0QcsThnWeSeaAA8 UIWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=FmLn1We4G4Wc3+AAT8RwU8DweP1AVqFc7zVXZuCzZmo=; b=hBX4p86WBFhZ95sqE3y7RqCkDZyCJHXgf6LMx+11YhxUFv4POp4RDzR5Ui2GLmfTLF xZ6ZaPdMP+6MapXo3TqbhfpyQJAX3/PangK6ZGgLuT7spsXKPKNVzTcyByG0s2PMtUQK 9ktUKSGyI4kwo8egSOzHCg5s1qK/wx/WGGaHdfzMJX8AeWJfgTiWDpcisQjNzmRjelom nUNMxR2X2t25qyjattgNZPBmc/ym5MYcAXWipEnL7pSSlKejwhb/oj1QTvwRwSp0AbkL KRvE4RfDqFbpvd8N6HkLyaBIp7exTpQBE9GxtX0DoIdMqAIHySkx0wmmLP8zqWgGJsL6 B3dA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533DDixd+xDc2KdZIEcwJGobz/mrWbQUQSqJX1abCWn+L+uTrZC2 Rp+SNdMzjgA8MR5Z6xnPYYM= X-Google-Smtp-Source: ABdhPJw1v7H7k6yM9iGIPYFgJsZUNT8gP2APXa+aEmDytxVbXnTxPz+b1iu1GcXuUFztt/xbV+nwPw== X-Received: by 2002:a05:6870:3395:b0:e2:6628:7195 with SMTP id w21-20020a056870339500b000e266287195mr7082207oae.82.1650671997391; Fri, 22 Apr 2022 16:59:57 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6870:c145:b0:e6:6ee9:6279 with SMTP id g5-20020a056870c14500b000e66ee96279ls775337oad.1.gmail; Fri, 22 Apr 2022 16:59:57 -0700 (PDT) X-Received: by 2002:a05:6870:6085:b0:e6:1315:624e with SMTP id t5-20020a056870608500b000e61315624emr3091785oae.256.1650671997048; Fri, 22 Apr 2022 16:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650671997; cv=none; d=google.com; s=arc-20160816; b=xQek9KxqXbR1Ki+v/dPpa6sHRtzhtuaQ/WmSZlnmvP9CceoGG9R23zOfRerz2mqqhf NLYXCklOK7e5+WefFS58eFbBpdwNuHpzRlq1w12Op1GGwRZKBX5onR7VVeW1OMhLwg/y MD9HKT0gslW1CaHZYI4lZ8WjSCygvjXDQ1hE8dUUUC12vz5ZacfNpXr2hKSfX8+cmuZG jM5ntMLMFoV1UqnVQ6ax3fqjUTWx6N4YEJRRJ57K1hlApdaWH7thvY19T7/RsKN1beb2 XQQ1mi+d5sWxRQEcNFiBNQ0AUO4W1xSnqIfbaN9Lcp2uCdS6N/Yv8GsAAFt5dN1DGel3 Xa4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=yl5BEWJN6NzzDBF27JsgmyYJ8T6EWzTCPC5F72UjgBs=; b=tHIFmy4aMvA8wAgjKdiA7Zcy0xWdvDtj5P8Z0mrPKsahBV9sOYSbxVbOtAJfRPU6Z1 flzlcnEyweWdG3XK0eOYgZluvVrKSkpDu0PjsXwKs4xkwhFXZ4LjCSsTp+hMsKexqGCa GGTqUvEwCaeweeSM6IP1vXE0lgT9H2ptsI+CMW4x+Byj76CT2fEyAOYuA/Etc+RXMDQ4 U8PW1NNtSG2dTTI221I7UL8CsMDj3y4e+FHl91/GjRcp97vEmlKUTS+LBZHyOAIQ11H6 9qkHcZ1ofXpynvD4NQ1gDDYrWeBlJYZWDxrbotStE+zzVplfqsMgEckOXOZC9pCHeoEt yHAw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTP id ec47-20020a0568708c2f00b000e208621513si998674oab.3.2022.04.22.16.59.56 for ; Fri, 22 Apr 2022 16:59:56 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id 04C6B20D62 for ; Sat, 23 Apr 2022 08:59:55 +0900 (JST) Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by gw2.atmark-techno.com (Postfix) with ESMTPS id B65B420D62 for ; Sat, 23 Apr 2022 08:59:54 +0900 (JST) Received: by mail-pg1-f198.google.com with SMTP id c194-20020a6335cb000000b0039d9a489d44so5833248pga.6 for ; Fri, 22 Apr 2022 16:59:54 -0700 (PDT) X-Received: by 2002:a17:902:8644:b0:15a:3b4a:538a with SMTP id y4-20020a170902864400b0015a3b4a538amr6981786plt.146.1650671993741; Fri, 22 Apr 2022 16:59:53 -0700 (PDT) X-Received: by 2002:a17:902:8644:b0:15a:3b4a:538a with SMTP id y4-20020a170902864400b0015a3b4a538amr6981777plt.146.1650671993494; Fri, 22 Apr 2022 16:59:53 -0700 (PDT) Received: from pc-0115 (117.209.187.35.bc.googleusercontent.com. [35.187.209.117]) by smtp.gmail.com with ESMTPSA id ch10-20020a056a00288a00b0050a51a95e91sm3410780pfb.201.2022.04.22.16.59.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2022 16:59:51 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.95) (envelope-from ) id 1ni3Bm-00BmZH-6Z; Sat, 23 Apr 2022 08:59:50 +0900 From: Dominique Martinet To: swupdate@googlegroups.com, sbabic@denx.de Cc: Dominique Martinet Subject: [swupdate] [PATCH 2/6] swupdate exit code: return exit status from main child process on main process Date: Sat, 23 Apr 2022 08:59:40 +0900 Message-Id: <20220422235944.2808227-2-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> References: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , child processes such as start_download take care of returning a valid exit code, but that code is lost right now. Instead it's possible to just have swupdate forward it out of the main process (currently exiting with success all the time), so e.g. swupdate -d with a failing update fails appropriately Signed-off-by: Dominique Martinet Reviewed-by: Stefano babic --- Note this change exit status for e.g. swupdate -d, so might not be compatible for some existing scripts that expect swupdate to return 0 when update failed with these. These scripts have however no way of knowing if an update failed without parsing swupdate output, so I think this is better, but I'm leaving the decision here to you. I don't actually rely on the exit code anywhere for this (although I did think of using it without knowing it wouldn't work...) core/pctl.c | 4 +++- core/swupdate.c | 10 +++++----- include/util.h | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/pctl.c b/core/pctl.c index ed5d49bbbf01..1c6e556d8721 100644 --- a/core/pctl.c +++ b/core/pctl.c @@ -429,9 +429,11 @@ void sigchld_handler (int __attribute__ ((__unused__)) signum) hasdied = 0; if (WIFEXITED(status)) { hasdied = 1; - printf("exited, status=%d\n", WEXITSTATUS(status)); + exit_code = WEXITSTATUS(status); + printf("exited, status=%d\n", exit_code); } else if (WIFSIGNALED(status)) { hasdied = 1; + exit_code = EXIT_FAILURE; printf("killed by signal %d\n", WTERMSIG(status)); } else if (WIFSTOPPED(status)) { printf("stopped by signal %d\n", WSTOPSIG(status)); diff --git a/core/swupdate.c b/core/swupdate.c index f06497fbebbd..3c9c8cb6a100 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -60,6 +60,9 @@ static pthread_t network_daemon; /* Tree derived from the configuration file */ static struct swupdate_cfg swcfg; +int loglevel = ERRORLEVEL; +int exit_code = EXIT_SUCCESS; + #ifdef CONFIG_MTD /* Global MTD configuration */ static struct flash_description flashdesc; @@ -118,8 +121,6 @@ static struct option long_options[] = { {NULL, 0, NULL, 0} }; -int loglevel = ERRORLEVEL; - static void usage(char *programname) { fprintf(stdout, "%s (compiled %s)\n", programname, __DATE__); @@ -421,7 +422,6 @@ int main(int argc, char **argv) char main_options[256]; unsigned int public_key_mandatory = 0; struct sigaction sa; - int result = EXIT_SUCCESS; #ifdef CONFIG_SURICATTA int opt_u = 0; char *suricattaoptions; @@ -919,7 +919,7 @@ int main(int argc, char **argv) } if (opt_i) { - result = install_from_file(fname, opt_c); + exit_code = install_from_file(fname, opt_c); } #ifdef CONFIG_SYSTEMD @@ -945,5 +945,5 @@ int main(int argc, char **argv) if (!opt_c && !opt_i) pthread_join(network_daemon, NULL); - return result; + return exit_code; } diff --git a/include/util.h b/include/util.h index 302ea04c7ba2..6a3295ce45a9 100644 --- a/include/util.h +++ b/include/util.h @@ -33,6 +33,7 @@ #define SWUPDATE_ALIGN(A,S) (((A) + (S) - 1) & ~((S) - 1)) extern int loglevel; +extern int exit_code; typedef enum { SERVER_OK, From patchwork Fri Apr 22 23:59:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1621283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=jnp8pzOu; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::c37; helo=mail-oo1-xc37.google.com; envelope-from=swupdate+bncbcwivbv7sugrb7ucrwjqmgqehg2zt3a@googlegroups.com; receiver=) Received: from mail-oo1-xc37.google.com (mail-oo1-xc37.google.com [IPv6:2607:f8b0:4864:20::c37]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KlWcK30R4z9s75 for ; Sat, 23 Apr 2022 10:00:00 +1000 (AEST) Received: by mail-oo1-xc37.google.com with SMTP id k13-20020a4ad10d000000b003531756b915sf3631459oor.4 for ; Fri, 22 Apr 2022 17:00:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1650671998; cv=pass; d=google.com; s=arc-20160816; b=jQXjbeIBECzxXNarqSxhAVL9Pufe8g4Ky0jcz1KesWSxBT8DqDQNAEPX03FT4m9STI W74G5UmjMDDCrUZzuBkkVjKAxIPlKUyT4iZl0rG3bl8eRPcDuUvUgKhMr2zTtCR04hDD X4ZHXXIsBbZo/j85A2GXMwyDjyGiS2DalBCUTvRdfgMG0jd1T1qQgLrC7ijWBZXul/ZG wdxRTfXT3VRKH/huknerSbl6UoJAQoZ/Gyc/E8aX7Rbwjr0CUVZNwCWHmiVXpPnMoK4O JMq+gi7Bxno7cedHw9rRdJ7Ifuvjq5sR55oDGE/53P+QP8X5QrmdVJoMv81+X5MKlcO2 3F3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=VVs8YPeg6aPhnHhlgCsNe/rhyZWg5pqrPFjQpe9OJGc=; b=BPGcyWw1zUytDPtOwwzurILG0EvRfekKvF9TBGX8rJjxpKbXELPDScvnYcNrMpwMhk P2u1VCN75ZLWB70zIokLqnQI3L2GPpZGlH1UN2ec6sTGrZVbQycbrCK94eFLPqUqCrU3 LOEG0SlM8d1Ezdm3CXGeHi+N/ZZTJ+Da8p2YPso03W37WlAjJCsahkGXLQ2R71GmwWMo uoO9kc75EUtAlfNlq/4WGkWSYjMTkBAGWUbBkZ6Ayd7RBInJAReUQ60iIkJ9NToDttac 4ohcbhy8H1zmCYVTGRxptKhZ7SSX5ioa/fESNqYen46EejmBztCvhcWb0k6n/o2TY4B2 8BcQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=VVs8YPeg6aPhnHhlgCsNe/rhyZWg5pqrPFjQpe9OJGc=; b=jnp8pzOuBSiJsYKGMSS4ibI8ToFkRniICZTqWi+oDVAOgDTopP2Pd1jp4uZx51Loxs c/+3N92cAkvHenjoutf9yqy77272S8FeRo3cWRCXIiaD1aYT2pCnqqNR3BoAg4/XQxeL eZJDh8b8aP9Kfs3qa1cTyIR0BMPS0rhsywuD4Q1DnTDoeCGR4Gr5Fz/EqrVgIYKeNGov OO8MZLipR1wu6M8Drjx9DCbyZwRVHixM++Dp9HrHvlwKeKAzlW/9bsH6M2M++p5rOjdH R+bC9P3GBs+qd04CU5dDmUXdZS7Y7vNYef899to7bpyHnSFjHVeQ/tnF7n/1fGl1ylPh qvoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=VVs8YPeg6aPhnHhlgCsNe/rhyZWg5pqrPFjQpe9OJGc=; b=L0SEr0Ipr5TXR3c4syBR4uBQqyJIckvE18Ox9Yxy/SCfqJI/+uFTXIE1aCJZweW1ZI sYFVHDX/nRo8iaCFATr8l92JyYiXu+cfrvauqL7RWaDpBH2+XNkj6s64/fYyN+h3YfbQ 6ziqx+TR2CyDAc4uiJTIOpv8iuDNiROzngJaTzZpE5FJHLUrwJfscDnGb8bO8TPt85UU 9t5yVOtAexPbSvbAU5kxTWIdPMvw4CYdZmaJ5/xeFN52i2vC0IYFiNgLaf875xe3+B6J oCX+TpcBxqJiTBqnwdEIgfOaZhkoRwliOjfmwmBunwvNe7J1t5x9oohBYEZwDYBbYhQy vCiw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5333TWspM6ejGFO6tMPMmNhY6mSzRWYohzC/9Bl8oPIS+wpB5Lt9 HlXi+lXLiQShAu8LKV/pg/U= X-Google-Smtp-Source: ABdhPJygeh1niRnJ6ETikUxl/rltaU8pPsMlTAGsgnyCKTcQf05Qy5CmRqmAA7lnMRlMs2JM9f1fTg== X-Received: by 2002:a05:6870:4201:b0:e6:47c4:e104 with SMTP id u1-20020a056870420100b000e647c4e104mr6804012oac.257.1650671998269; Fri, 22 Apr 2022 16:59:58 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6870:d296:b0:e2:fa0:dca4 with SMTP id d22-20020a056870d29600b000e20fa0dca4ls764597oae.6.gmail; Fri, 22 Apr 2022 16:59:57 -0700 (PDT) X-Received: by 2002:a05:6870:a985:b0:dd:fb7f:8e3f with SMTP id ep5-20020a056870a98500b000ddfb7f8e3fmr3160942oab.267.1650671997897; Fri, 22 Apr 2022 16:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650671997; cv=none; d=google.com; s=arc-20160816; b=auUt1xmPwf5uUzXO2ntwCXm5dfL5cPTvN2ELBS2BlwHhd8vHglfzkkIfaDFfD5rvNW FjS8kRF1iqQf3AYmvE68PusOvbS3J8J+gqz32uAXz4W1W2+5+r7lFqroGNLOQaEAMmk2 i4O5md7Tt6VU6e7t0lAQT5XdpRnCuCI+OryzMiuQueYdyLLpGf53N+egMhOifAGoRm4O SjgUy2tD/256RjkzN1DTxApEwkCRKMz65sMnWUGfw7Y4tTqkxCUFp/i4EijKJ+ba4+Py Hg1mG81Bv6r6ENcGN0aCkxH8S710WA4shaDmP4zc7SGPA9vJfLnwasiq0LUlkdmiVeP/ buzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=AvxSIDnbOY/TKDM48UkU/uSzdxq62qLu/JPMVRTUEiU=; b=ZafWd2lEircf1sG+bADimGdKaMUhfLRCRhGj+vK+9oeXKDg3leivBCVClDE2BbUgQh Yxm7pVRiPOhvKA6153df9mMwRX9CcLNwccF+29IzRxNMgdPrQML3e87bc73jvK2oNV7Q 6ZFeSVmLGIthRonoTQp9fDZWm2cy/58ITpYg8sE2YPuJ2/Bpq1S+jWFNFy+Dt9pz4eUd vVKhx5HPyJsgNPgPcPm9ThSMwEeNVV4JAiWr5kI7Zx1SoO/KZWO2sxMBJ8bjh6DQOKSO smcV7q4mbj5zTESS06ZcVDGnBGDLBcs3h6z8M00TrXI+ppKY/IJtC/R3uzr8sCe2uoRB CXcA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTP id c22-20020a056808139600b0032235b7f6aasi1215881oiw.4.2022.04.22.16.59.57 for ; Fri, 22 Apr 2022 16:59:57 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id 7A38D20D60 for ; Sat, 23 Apr 2022 08:59:56 +0900 (JST) Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 5ED4520D60 for ; Sat, 23 Apr 2022 08:59:56 +0900 (JST) Received: by mail-pf1-f198.google.com with SMTP id j8-20020aa78d08000000b0050ade744b37so4258400pfe.16 for ; Fri, 22 Apr 2022 16:59:56 -0700 (PDT) X-Received: by 2002:a63:1215:0:b0:39c:fa33:9427 with SMTP id h21-20020a631215000000b0039cfa339427mr5984673pgl.296.1650671995341; Fri, 22 Apr 2022 16:59:55 -0700 (PDT) X-Received: by 2002:a63:1215:0:b0:39c:fa33:9427 with SMTP id h21-20020a631215000000b0039cfa339427mr5984664pgl.296.1650671995118; Fri, 22 Apr 2022 16:59:55 -0700 (PDT) Received: from pc-0115 (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id g15-20020aa7818f000000b00505ce2e4640sm3531217pfi.100.2022.04.22.16.59.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2022 16:59:53 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.95) (envelope-from ) id 1ni3Bm-00BmZK-79; Sat, 23 Apr 2022 08:59:50 +0900 From: Dominique Martinet To: swupdate@googlegroups.com, sbabic@denx.de Cc: Dominique Martinet Subject: [swupdate] [PATCH 3/6] start_download: return EXIT_FAILURE instead of result on failures Date: Sat, 23 Apr 2022 08:59:41 +0900 Message-Id: <20220422235944.2808227-3-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> References: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , using the swupdate status from last update is not consistent with what other modes (at least swupdate -i / swupdate-client) return, and might miss weird conditions where result is IDLE for some reason that would be success (0 value) return EXIT_FAILURE like the others Signed-off-by: Dominique Martinet Reviewed-by: Stefano babic --- This only makes sense if previous patch is applied, and doesn't matter if it's not as that exit status is currently lost corelib/downloader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/corelib/downloader.c b/corelib/downloader.c index 0debad0b7486..6bff9c7f2b82 100644 --- a/corelib/downloader.c +++ b/corelib/downloader.c @@ -163,5 +163,5 @@ int start_download(const char *fname, int argc, char *argv[]) free(channel_options.auth); } - exit(result == SUCCESS ? EXIT_SUCCESS : result); + exit(result == SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE); } From patchwork Fri Apr 22 23:59:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1621287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=QwMmEPpX; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::d3d; helo=mail-io1-xd3d.google.com; envelope-from=swupdate+bncbcwivbv7sugrbb4drwjqmgqe7ls7yma@googlegroups.com; receiver=) Received: from mail-io1-xd3d.google.com (mail-io1-xd3d.google.com [IPv6:2607:f8b0:4864:20::d3d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KlWcT65Fzz9s0r for ; Sat, 23 Apr 2022 10:00:09 +1000 (AEST) Received: by mail-io1-xd3d.google.com with SMTP id x16-20020a6bfe10000000b006409f03e39esf6444499ioh.7 for ; Fri, 22 Apr 2022 17:00:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1650672007; cv=pass; d=google.com; s=arc-20160816; b=LpT+9toKZC9RPdI8uy444r98nD8QtXvWQdDgFJ0sg7CF1l5N4CuzxJGCh7ycpvwEVl TzZXCe1D9h9MxpSyDollDYPGENFtwzRADDQu2MVv6kmMWlWFZB52U5u5LJiSXHtZr1wO fsPkmkW4O2olP4Oo6/lQR3G/H5OEhoS2Io1LWZt+/wRM//tHa/nvyDlExop+7rvxGkFQ jCLUbrnpRoYHwE2ep7xuU21Ve4myjFGDECZSQ/jxT8PPfStrP5hQB5CyzryGWKZ+7z5A vNnhtwg18m3L1sBBRyhL150+VGWjnzQqmXSF1HFSDvebB5kghXDMzXCjsH6p8r+qRRx2 K0ww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=IJRgYQ141oQT9GfBBXc9/lqq6r/QiGa4e7TIF/GX1Dw=; b=kDocy57iARWONewsym296j25GKRNZ0zMPzXFC52l+wBwDicZaaNZpF7wOwHpf4OboG r0oNxqcShFSHjYg/64NvVLtSkog9kZ2f+Sszs19VnnxbI736FCnXpGikNWzvXcIzxw6+ PpK6ziGZQldczWr9TMP/4xAhZ/7Bhwmo2nRcUz67+JTXUYdAXy2pMTGt+IsEuuYbEOtq nYpeGylItygtXiNev+gF9hBwIl4bhzLBRlveTQGkXZqeele4HcmVm4VJqbBAdJd6yljh iVaVMCQFTXzAhAOwLpkYp9/JC99LV+aNNB+3umoTUs2W7y4xcnKgX5tIeYtL3Jkd5R5c +DWQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=IJRgYQ141oQT9GfBBXc9/lqq6r/QiGa4e7TIF/GX1Dw=; b=QwMmEPpXV6ComgNq6Tr8EKo3Qiv4Y1d0b7tFBaIIwgaGXhFyjA2jupZsyLLXjoRO+k +1pAip5aJtP5uYXX1K16wUWVh0oW9zQQ1T93Dg8eOcQvA833KhXWuW3ejNzqFUUIukFI fydhcRWToKZ8FL74jfz1vMmmT2nGC9kftENDcxtaRx+4GcEThvbMk1nrWib6ZTWtMZsu 4JhHdd/HCjxpK5ycjwX6n3ZtRYb2+KVa5BeZLdjbJj6mY4rHf0i7l9bvLzLoLq7WqbH2 +lz8diiWc+QTosnCKJE9vwwwa14EDbzpQ48YhmO0hMWMxR1Pypmu/TvCdGIiAz6bt9pq feuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=IJRgYQ141oQT9GfBBXc9/lqq6r/QiGa4e7TIF/GX1Dw=; b=1WgmaL+TUwaqRWwUQ+OWhfHy+8h7bzEGKxEtTCHNRskxVV40fLTgEUygMeQ45/GwAv qdcyLTs+vN1nxdUbm2yL5zKC+kXLuahbdUOgJekeJQ599cUNv1+Ux/l/aiy9OXmNh6QT hpofia4Fe3Y1t+CSxpLHaXKW8wH0EqXBL9ZmRPdpfEpLJcoztdtSxiWIMyjil0sRVLh8 SjGXejiFykVn1PGWZhF7nhn+zrIsRHn5Yi3nZB5C0p8uVt89n1qhJh35Q9Sg9DTMmmev SzDL+lOJp4teNlHor+RS6A2BNC8i1NYq7lMMsJxADXRwpM8qaY2SYEJCNT8pZskUFJuZ 3HBA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533ygJ7JA9FTjBnd0+IH7Nz3djPTY0VNprplknG9fa9HbjKccUUi asd0i19ykDK1++oiLdUXckA= X-Google-Smtp-Source: ABdhPJxtSU1Q9UqUsAZ3WzugC94LFHjRe8qxcp8X8XFZ+MDT5u4fvHjRbyKxA4A50Zw06e87LXmgTQ== X-Received: by 2002:a6b:e918:0:b0:654:8aaa:abd8 with SMTP id u24-20020a6be918000000b006548aaaabd8mr2988388iof.57.1650672007474; Fri, 22 Apr 2022 17:00:07 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a92:c563:0:b0:2cd:7bd6:e895 with SMTP id b3-20020a92c563000000b002cd7bd6e895ls606863ilj.5.gmail; Fri, 22 Apr 2022 17:00:06 -0700 (PDT) X-Received: by 2002:a05:6e02:12e7:b0:2ca:b32b:f011 with SMTP id l7-20020a056e0212e700b002cab32bf011mr3006964iln.284.1650672006887; Fri, 22 Apr 2022 17:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650672006; cv=none; d=google.com; s=arc-20160816; b=RUdu59gAXIdXYx/hqNuGvvFt0Xxw3nzdPpAfK4hsQlXa4sNujXQlk6WXlZxG1m4YW2 XCnovX90CqsJ1SWHr+luFfX+jNzboQPWnyWW3c0MgKkCK6z8Jko/Nm1WY05ojIJuV7j+ H8ri6BoH+VP1dTx4ONzk/tklFs7GKAqfgcu0VxRNr/9HLASvV1S4LKo2zrL5NAdFmRwA iC33WkxZbt1U0PHg1b3NkabeGVlA4I+9Q/ing00ELf5rKkUGNoUSDiQeCPP9eGLk1ROB VyUl9ebutVLJbI2pCeKGgCDnYTsXVKoxhrUl3rMkgZlJXb7ouMojuAxjSw4oEHrq+QKj H7Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=K+mhMMPSkK81/BV0c3/1/AbnWTd+RL8UExmrC72W1J4=; b=lgSV88UIy8NqVsiUZh710ai50SvuXjGWArIg7AEPTEX9ObTE1HAOBLc12cwkuvj1GR kRh8nw3u0cwkR3IV7/4PYjB1pkV66e3HemAgLy7XTtCxq4wpQlO5kxJezakQTGMWiZXZ sfrpexw3ESdWzb8WM8insgyTdG2a8u8t9eCZMGVzSNm/IEgnb8JTJWzZcE95nu9NljIM bO+KaYTJXk+QEuFd8GGE17B5DNBC1S3tFIIbL4Wh+XnGulk9We2L/Mj0zGCu3SC56B7O nzDavXZ3/nC/7MrMMxNn1ZJx0Pit4wMlKh9U1WcXv71mcdTHcaHAStsIetthcqfwM/Qh s5tA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTP id i15-20020a023b4f000000b0032660e40519si542895jaf.5.2022.04.22.17.00.06 for ; Fri, 22 Apr 2022 17:00:06 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id 06CDF20D56 for ; Sat, 23 Apr 2022 09:00:05 +0900 (JST) Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by gw2.atmark-techno.com (Postfix) with ESMTPS id E693420D56 for ; Sat, 23 Apr 2022 09:00:04 +0900 (JST) Received: by mail-pf1-f198.google.com with SMTP id g5-20020a62f945000000b0050578328060so6305712pfm.17 for ; Fri, 22 Apr 2022 17:00:04 -0700 (PDT) X-Received: by 2002:a63:1252:0:b0:39d:aa7a:c6e1 with SMTP id 18-20020a631252000000b0039daa7ac6e1mr5984548pgs.436.1650672003761; Fri, 22 Apr 2022 17:00:03 -0700 (PDT) X-Received: by 2002:a63:cc0b:0:b0:3a4:90c:ded4 with SMTP id x11-20020a63cc0b000000b003a4090cded4mr6066662pgf.260.1650671992715; Fri, 22 Apr 2022 16:59:52 -0700 (PDT) Received: from pc-0115 (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id o19-20020a17090a421300b001cd4989fec9sm7313925pjg.21.2022.04.22.16.59.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2022 16:59:51 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.95) (envelope-from ) id 1ni3Bm-00BmZN-7o; Sat, 23 Apr 2022 08:59:50 +0900 From: Dominique Martinet To: swupdate@googlegroups.com, sbabic@denx.de Cc: Dominique Martinet Subject: [swupdate] [PATCH 4/6] network_ipc async_thread: fix hang on failed update Date: Sat, 23 Apr 2022 08:59:42 +0900 Message-Id: <20220422235944.2808227-4-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> References: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , if a update is large and fails, it's likely write_image would fail. Old code would just exit there, quitting swupdate but a recent cleanup made this just exit async_thread without calling the end function, so the caller would be left hanging waiting for an update taht will never finish. This can easily be reproduced with a script that exits immediately with a failure code followed by another 'large' file, with swupdate -i or swupdate_client Fixes: 626d83f8819d ("IPC: do not call exit") Signed-off-by: Dominique Martinet Reviewed-by: Stefano babic --- I can provide a failing sw-description if required, but basically a cpio with - a small script that fails immediately - whatever image that would be ignored fails reliably for me ipc/network_ipc-if.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ipc/network_ipc-if.c b/ipc/network_ipc-if.c index c8a6cd02c72f..bf946648edcf 100644 --- a/ipc/network_ipc-if.c +++ b/ipc/network_ipc-if.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "network_ipc.h" static pthread_t async_thread_id; @@ -44,7 +45,8 @@ static void *swupdate_async_thread(void *data) if (pthread_sigmask(SIG_BLOCK, &sigpipe_mask, &saved_mask) == -1) { perror("pthread_sigmask"); - pthread_exit((void *)-1); + msg.data.status.last_result = FAILURE; + goto out; } /* Start writing the image until end */ @@ -56,7 +58,8 @@ static void *swupdate_async_thread(void *data) if (size) { if (swupdate_image_write(pbuf, size) != size) { perror("swupdate_image_write failed"); - pthread_exit((void *)-1); + msg.data.status.last_result = FAILURE; + goto out; } } } while(size > 0); @@ -69,20 +72,22 @@ static void *swupdate_async_thread(void *data) swupdate_result = ipc_wait_for_complete(rq->get); - handle = 0; - if (sigtimedwait(&sigpipe_mask, 0, &zerotime) == -1) { // currently ignored } if (pthread_sigmask(SIG_SETMASK, &saved_mask, 0) == -1) { - perror("pthread_sigmask"); + perror("pthread_sigmask"); + msg.data.status.last_result = FAILURE; + goto out; } +out: + handle = 0; if (rq->end) rq->end((RECOVERY_STATUS)swupdate_result); - pthread_exit(NULL); + pthread_exit((void*)(intptr_t)(msg.data.status.last_result == SUCCESS)); } /* From patchwork Fri Apr 22 23:59:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1621284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=OZkKIKo8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::539; helo=mail-pg1-x539.google.com; envelope-from=swupdate+bncbcwivbv7sugrb7ecrwjqmgqe5gx557q@googlegroups.com; receiver=) Received: from mail-pg1-x539.google.com (mail-pg1-x539.google.com [IPv6:2607:f8b0:4864:20::539]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KlWcK2kQRz9s3q for ; Sat, 23 Apr 2022 10:00:00 +1000 (AEST) Received: by mail-pg1-x539.google.com with SMTP id q13-20020a638c4d000000b003821725ad66sf5806590pgn.23 for ; Fri, 22 Apr 2022 16:59:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1650671997; cv=pass; d=google.com; s=arc-20160816; b=NCHuD+EupQWECHnVS84fzn29+0Gxo5logu+dSlnABr1PZI40cHvE9uol3matSNv4d5 U34fHMCxSVs5jf0Z0x6MLPRU8XhduWdrfUmHhzIN0wp4hX452zGB33kWAcJz2oEDWuFR y2lLMdYdcHHxlVb82irM2bEHi9KvleaNMGtd8+3kJrObW55b5r8wtZDKY1WE5v0lc9Gq p7dPxRsBHO7jmyo6KgCWIWHXz0kfW6WofEQoesvX4a6y+biZ3VStJVu0cgLnCcsuLqtd lPRUdCPzGhHROkIew2o5URmscrz3wNSWOCMoE+R6Q8nTN7yCRpFtgTi9OCLUlBY2513W 16ZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=e9qebpFWshdGvo3tweJxQepIlzPo7LUL6LlbmZxDK08=; b=iHD6y4rppEWrhDkDD9SupkghonNGcuV2ijaldesFjBfBJrrCSPIz5I7b/Fv4qkY43r tRhGHfoGdDcQ1di3xKqUctCF8Jk+rVIwTrnDdGLRFTigns5dmLvDvKTbEfeiuWKKgfyw NENVqqmCL2UWQFo/oDix0PEVbidHa0Cgq+7yrmviTzkWC17WhZKRsNpID0j/XXf+FeiZ mejDuvzQVHeIA1PpjhVXogtAExkBEPhTDHvARXQ+ydZozYPORmrzYhiYjO89hvZaFJK3 y113ScvsPCuI5k6Wm0EY5KKbjnp1wBGv21UrbqUShY9rkbksU4rIbHys8m3xsRc4VAgS iDiQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=e9qebpFWshdGvo3tweJxQepIlzPo7LUL6LlbmZxDK08=; b=OZkKIKo8U6Dlk/hZIQwSCT1HT9IvalZWpUDS43kiRpOWLjeeJBHKQUB6Y5JxwaYHTB mJ8kCTxw4yhDUtCHN0ER7PIhSg1pwEL/lQvoI0JEHnCe3+ft/qObIoHdR8B5mwloLrTE Fq6lx/CY1wcsaUBfN2WM2fuYAusaZuMdpTkgf3Xd8UF6xVwYnpaw1y7YoxL8oVu1E1wf 2AiCk45aQ+oqSHeQhghaBX5mJTS6pQ4fPMLEtWp2g4s4YljLfvcxT9CzvpqCdHr6pNk1 adbaNkIwrhifuzgHP/IBcpmlY+RpAbqGJrjTzEEJwTpXpz8yPk/DCk9UBvdMGDva2b+f T3RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=e9qebpFWshdGvo3tweJxQepIlzPo7LUL6LlbmZxDK08=; b=BppfSxrmUYNZ8MUvq6OzZaODWhnIn0q8jo1RblyrlRqQlLoOR8JiQB5ws/3kBYEzz5 kQ04Fn8GkWaDJgg4deNrEyE2Dkhno8bxfLvifClkqV6YDK/U4lDyt8CgLcnbchigp9/x z0rKebL6UMkuAJpWahtex0R/FIwtZJE9HcSVvvQrPA5YUhCkvujhOeAB5Gt19f3h5Jm3 O6rIFZmxbAIRkvnNNeSQLtTJsYBCbPgY2CoOvnClH2QCBfB/ZTbZlcCsZy+WEkTkyj6r M2wHlR0u7alTsEkwzac1caHsnB28kGEw+w/zv9DAD3YZDo/7v+9NT31n6/E9THifv9X+ t3yw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532LPllRAMTvqY1E9O57km5szpZF1H1lnsR+C0iaMMXPRgAtZvPl LuyUkLalwsbceEBscqm8itQ= X-Google-Smtp-Source: ABdhPJzm/wRf3XM2inh//TfoIJ8R1iH2/moZ8WJwZ2rbPBRgnIGh+ysC2Yos9Ks5Jf1Wra9tjM/X6Q== X-Received: by 2002:a05:6a00:1988:b0:4fa:c15d:190d with SMTP id d8-20020a056a00198800b004fac15d190dmr7376394pfl.44.1650671996544; Fri, 22 Apr 2022 16:59:56 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:90b:4cca:b0:1d5:7c21:7e07 with SMTP id nd10-20020a17090b4cca00b001d57c217e07ls6275037pjb.2.gmail; Fri, 22 Apr 2022 16:59:55 -0700 (PDT) X-Received: by 2002:a17:902:b286:b0:15b:335b:53e6 with SMTP id u6-20020a170902b28600b0015b335b53e6mr6937299plr.169.1650671995852; Fri, 22 Apr 2022 16:59:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650671995; cv=none; d=google.com; s=arc-20160816; b=UDxczy7uQDgEM12G2JCcEdn/r+aguofF3VWv6Dr7OliVDkcQMdjwebIkJ7l/GfcNAH gpdFa9JVMl+nk5/mNrXGuUWAqxugFIiH5FaokOS8IS7hqaFjvt5mpm0XVoDmpElste77 Cy09a0mwXAYAico/jMCq2E8ZVNhMWhTZT1aioToM4FDYE6pW7kqLeaSjDt7hmW8HxTlL lPj5xFxvQbR2vv6JCP8tjlHElvhGl8xOajytAEaZfXDEX5a8PGF3lOjfVE10u32y/4zz rmGI3v00ux4NLDEsyXzIqU05c+155sd1zvYelhpkKfeA4TdKHk/sGuyO2kJrtbtWDm4N hjEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Lt71Vl9sflgMefitFLnTUvcxMpUbhI02wC0QS6Dx6lw=; b=Yu/+3TA5uf9jFRqdrBKoP59B71XWx4luH3shF10bvQ14Of8qifcXskQetq6DQWZk9U gMTQwd4q5GiSTT4d8LJwqzzoIMi6hIQ+U1eLSm1SvtM9UZIz2GhCDPKNps3KK1IuiCkF aSyEkwp81F1QEIcP81lP5hC5YcmUA/IjCDm5jDAfqzaynehCDrJj1KzpRESMQJk+RTE+ gidlGAKsjA2ZRV21ZJR1AQBhfY/1RzijfmGGhM3f041pUGJmu9Qrawl/wbp7deDd/fL2 ltIjgInQFd5vfRN5fkGwPCT/B1rluDdI6WTRLbo9Ykk7L7Q/YSonocNZRiohyKjLHYmT A+ug== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTP id hk1-20020a17090b224100b001c69d267568si938733pjb.0.2022.04.22.16.59.55 for ; Fri, 22 Apr 2022 16:59:55 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id 9D61820D57 for ; Sat, 23 Apr 2022 08:59:54 +0900 (JST) Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 8AB8F20D57 for ; Sat, 23 Apr 2022 08:59:54 +0900 (JST) Received: by mail-pl1-f200.google.com with SMTP id z5-20020a170902ccc500b0015716eaec65so5571281ple.14 for ; Fri, 22 Apr 2022 16:59:54 -0700 (PDT) X-Received: by 2002:a17:90a:410a:b0:1cb:a279:6679 with SMTP id u10-20020a17090a410a00b001cba2796679mr18837210pjf.211.1650671993419; Fri, 22 Apr 2022 16:59:53 -0700 (PDT) X-Received: by 2002:a17:90a:410a:b0:1cb:a279:6679 with SMTP id u10-20020a17090a410a00b001cba2796679mr18837196pjf.211.1650671993207; Fri, 22 Apr 2022 16:59:53 -0700 (PDT) Received: from pc-0115 (162.198.187.35.bc.googleusercontent.com. [35.187.198.162]) by smtp.gmail.com with ESMTPSA id u12-20020a62d44c000000b0050d17e069f2sm369770pfl.10.2022.04.22.16.59.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2022 16:59:51 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.95) (envelope-from ) id 1ni3Bm-00BmZT-8l; Sat, 23 Apr 2022 08:59:50 +0900 From: Dominique Martinet To: swupdate@googlegroups.com, sbabic@denx.de Cc: Dominique Martinet Subject: [swupdate] [PATCH 5/6] install_from_file: initialize and take mymutex earlier Date: Sat, 23 Apr 2022 08:59:43 +0900 Message-Id: <20220422235944.2808227-5-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> References: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , if async_thread finishes really fast, it's possible it'd try to call end callback to signal us before we're waiting for it, leaving us hanging here. This completes the previous patch for swupdate -i Signed-off-by: Dominique Martinet Reviewed-by: Stefano babic --- (side-comment: shall we use that occasion to rename 'mymutex' ?) Note I didn't try to reproduce this bug, but I've seen it on other programs so I'm sure this is wrong. I actually did that change first so I didn't try the previous patch without this. (Thinking about it again, it's almost impossible to hit right now because the current async_thread sleeps 1s before exiting whatever happens, so we have 1s to get to that lock initialization/cond wait, but that doesn't make this correct) core/install_from_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/install_from_file.c b/core/install_from_file.c index 2230a4f88f3b..66b66372c7cd 100644 --- a/core/install_from_file.c +++ b/core/install_from_file.c @@ -88,6 +88,8 @@ int install_from_file(const char *filename, bool check) if (check) req.dry_run = RUN_DRYRUN; + pthread_mutex_init(&mymutex, NULL); + pthread_mutex_lock(&mymutex); while (timeout_cnt > 0) { rc = swupdate_async_start(readimage, NULL, endupdate, &req, sizeof(req)); @@ -104,10 +106,8 @@ int install_from_file(const char *filename, bool check) return EXIT_FAILURE; } - pthread_mutex_init(&mymutex, NULL); /* Now block */ - pthread_mutex_lock(&mymutex); pthread_cond_wait(&cv_end, &mymutex); pthread_mutex_unlock(&mymutex); From patchwork Fri Apr 22 23:59:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1621286 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=by0XAV67; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::338; helo=mail-ot1-x338.google.com; envelope-from=swupdate+bncbcwivbv7sugrb7ucrwjqmgqehg2zt3a@googlegroups.com; receiver=) Received: from mail-ot1-x338.google.com (mail-ot1-x338.google.com [IPv6:2607:f8b0:4864:20::338]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KlWcK3K0gz9sBy for ; Sat, 23 Apr 2022 10:00:00 +1000 (AEST) Received: by mail-ot1-x338.google.com with SMTP id r28-20020a0568301adc00b0060547f4fab0sf3421461otc.1 for ; Fri, 22 Apr 2022 17:00:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1650671998; cv=pass; d=google.com; s=arc-20160816; b=zw3CxumuY1Hta4JNX4iIqebIBtOE+tZ47stj31dwUfnA1BfoNoMI6dpZ1ruQThUprC LQCk6s+n7OefGFfnNx2QCQZD4JSrEDxMK3HjGBxy86aiYGc7ZgqGfcIZb8YnFD10xS+u FM7obKaheAbdsU8rsE8kysf/y/YU9+2GVRCjZJLBraYU5gvCM+qdgklrKaXBUdM3G1Bu 4DY1quVdDWXfAnc48gtNYgoW1VJJNiBwZH7eMqLY+zELH1H4Zz2FGQ4udeamcDba1ZT7 tDLlUJaXfs8/V9jJ7PyEFiwe9rvTs1+1YoFkVtsFg/Ep0No7BqxMhJLuhvmwb3JPZgaN /Y5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=q2C0IXLC5jBNYxn/WIjylR49TN/bc84wCqZCRJ3l4Cg=; b=FMKo2R7X8+ILG3D+I3iiN2AkdYQoizNPfWfpVPM08rufHIxakBIQre6DqP5GVxlU6l e/Jfjlo1zT37fi4N4wjmhpEjN+9hc7xOh0LaKlp2FG1vFHzG1gQTpp1AsJ7ZJbz8sPm3 BLs/oV5Z8a0Axwnjcppky04g+7rRDy3LutxuZ8ta2EiJ4W14W7CLD4C7SYoPLkY6w3Bs 8ojqrKA1FfHz5riUy2FhxbQubO2RQUHfqze49MG1e9jVXnLOBWw+OXNoLNvQBcUhKuRc ockOpaTAqfsLpyHN+xYGvSMGC8EMl2HqtY5dVI9VOxXGcmXBBMEj6w8CjJxRN1MhzbCv h4+w== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=q2C0IXLC5jBNYxn/WIjylR49TN/bc84wCqZCRJ3l4Cg=; b=by0XAV67hVd3Z5vk4oQFEUC+s8PNv3TdZGUFey+p2pzOWdYRXCNw2Oa8ddgl6heYf7 4HPUCkYIY3iynvOhND4ox0gqlQWm1qle5L5Y9c3qvN3j71hBo26IM/vTiLCVyKe6nqX0 im1CvRpH65UzvQ3IrzONckbId5l7CFRBdeP9rcO2F47axdlt3WLvToWacl7eAW948C+r wR97RzADIZDRj0lWPLiAxIuQv85JNqX1Vyye7KBs/gMjJ1bixo8UogF6rsQA0ac9wlsj vsDvWSMk8+Ow9TC7wuncI2JTG5XHbGmt2+wJBS84uxKGMrmy0xz3u2SZJzadzlg6i1zX HKpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=q2C0IXLC5jBNYxn/WIjylR49TN/bc84wCqZCRJ3l4Cg=; b=jynDAJyaRF+vXKxQfkDHzlEy7V7zaDq4Q2ujSQyRS8nGDmYxei+CcH7JuRL/i68QDz XXgKzn1Mo73mzsIMSsgIe1nTyd2lW+OFXT6yjPCHISgmRan5MtSxEJlMx1/KozWtm0s6 zRL3syfraLtC8ppPrIKC0xABB4taJ2749T7mB1qCm+XkzFm9vsRrSNVlzX99VQqXvycl rBkakYqY7KHbrgJ9wn1Bccdqva+gzwffEyjFgOc4DBRaj6MkK4Cx751SBPwkLVNkziEV zTItFArY6s5dOrUzK35dmraiFzSOkqR+Gt8ZuUNKnU8AioCvJ/xQzN5p01TRigT1/2wt cM/A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533jzTT7dQ/5rbM5F93fj+crVu1g0+ciYUZ7U2dSjnpH6vh1IfxO ksANjETkbHFpyiVI/UAvHY8= X-Google-Smtp-Source: ABdhPJzo8sj7VP7etLY7IpX/Sw+egt13jypDVGJkHTWxeqHRLsHZNGtBlpWzeUQfuQ25KMAMip7LJw== X-Received: by 2002:a05:6870:b68e:b0:e5:c836:882b with SMTP id cy14-20020a056870b68e00b000e5c836882bmr7122887oab.177.1650671998253; Fri, 22 Apr 2022 16:59:58 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6808:23ca:b0:322:ac8e:f9e9 with SMTP id bq10-20020a05680823ca00b00322ac8ef9e9ls805012oib.4.gmail; Fri, 22 Apr 2022 16:59:57 -0700 (PDT) X-Received: by 2002:aca:b28b:0:b0:2fa:6d40:4b3d with SMTP id b133-20020acab28b000000b002fa6d404b3dmr7914294oif.67.1650671997917; Fri, 22 Apr 2022 16:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650671997; cv=none; d=google.com; s=arc-20160816; b=SI8DteTw+B4yI1B6vCUO7C/IbrBWe7wuOhC5uhzx40+T7HdZM4Uv9jt7CXOtKb150j CDGKtIbI4OA3/XYcO0IrWGSN7yCdl1I7ScGRF6UTtn8tCkU2UfBtMwKvRV2cvEISU9FT rcoQMjEqv4Oz1lsB0fngJYijFR3URSYxkCXwxYH5QYN5r+Lxg8VcY7DT47im9haQbADM ZX+H5N/d3fS/h1Gxk6giplY94Y3hUgRFZWPerD7PUnRu5k0qe/Sde446xSsPQVG/6b/v mHiXAo0ee9cULV8z1hjwq1/BFwaEjXzzKyEwAfYJ1LRdgBe1FMSNfsc5wnIGs4gXmF/H YMLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ocx43iJ/18kVHIkOK8sORAQGj3XC5Kv0vDpkwI+k1YA=; b=fFNu8ubxqLmI6J9f1q4UV3SQ6qvIc8kjvXIVOqY3CzCSPxqRRiZ9r4HSLcBXqAnzaN AIcD4ii9TQBLebsAV3SG/mjy7NhjJ7YwToZlgrP+CL9aCmhYYhRdWJvL1jfn4lYML6Tf mg5KBqzV4UGd+VH+oVqdis0odmr3PcYlm/Pc4rR4T8UqfSjfyyTFF1POyo8qp2nsnf75 /+EHZoTcwZ2L/T/yCoow3VqXcrqdcPQW14fW7cRR6kfacZmuu8ymVA5WFbi16N7xUFmd OYshFBw82ejgBDjmqIiVRDd2qe5N5IMYALDI20pLzoxRRawgPDKizErC+xhxwYRiaEXh 1gQw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTP id i26-20020a4a6f5a000000b0033a52ed3b6asi959684oof.0.2022.04.22.16.59.57 for ; Fri, 22 Apr 2022 16:59:57 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id F3AA220D68 for ; Sat, 23 Apr 2022 08:59:55 +0900 (JST) Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by gw2.atmark-techno.com (Postfix) with ESMTPS id CDC6920D68 for ; Sat, 23 Apr 2022 08:59:55 +0900 (JST) Received: by mail-pg1-f197.google.com with SMTP id z132-20020a63338a000000b003844e317066so5822052pgz.19 for ; Fri, 22 Apr 2022 16:59:55 -0700 (PDT) X-Received: by 2002:a17:90b:1bd2:b0:1d2:9340:d02b with SMTP id oa18-20020a17090b1bd200b001d29340d02bmr18885864pjb.1.1650671994775; Fri, 22 Apr 2022 16:59:54 -0700 (PDT) X-Received: by 2002:a17:90b:1bd2:b0:1d2:9340:d02b with SMTP id oa18-20020a17090b1bd200b001d29340d02bmr18885853pjb.1.1650671994544; Fri, 22 Apr 2022 16:59:54 -0700 (PDT) Received: from pc-0115 (162.198.187.35.bc.googleusercontent.com. [35.187.198.162]) by smtp.gmail.com with ESMTPSA id l2-20020a637c42000000b003644cfa0dd1sm3023117pgn.79.2022.04.22.16.59.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2022 16:59:53 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.95) (envelope-from ) id 1ni3Bm-00BmZX-9g; Sat, 23 Apr 2022 08:59:50 +0900 From: Dominique Martinet To: swupdate@googlegroups.com, sbabic@denx.de Cc: Dominique Martinet Subject: [swupdate] [PATCH 6/6] async thread: cleanup thread id and state variable Date: Sat, 23 Apr 2022 08:59:44 +0900 Message-Id: <20220422235944.2808227-6-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> References: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , async_thread_id was set but never used, start_ipc_thread returning -1 which isn't a valid pthread_t, and handle used as a bool with a weird ++ pattern: clean this all up by replacing handle with a proper state enum (init, started, done), and join when we try to start thread again after it's been done successfully We still never join the thread when exiting after it's done once, nor do we care about its pthread_exit return value, but at least we don't leak resources everytime a new thread is started Signed-off-by: Dominique Martinet Reviewed-by: Stefano babic --- This is mostly a cosmetic change, as I saw a warning for the return -1 on musl where pthread_t isn't an int. It doesn't solve any hard problem for me. ipc/network_ipc-if.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/ipc/network_ipc-if.c b/ipc/network_ipc-if.c index bf946648edcf..ed0993929834 100644 --- a/ipc/network_ipc-if.c +++ b/ipc/network_ipc-if.c @@ -24,7 +24,11 @@ struct async_lib { terminated end; }; -static int handle = 0; +static enum async_thread_state { + ASYNC_THREAD_INIT, + ASYNC_THREAD_RUNNING, + ASYNC_THREAD_DONE +} running = ASYNC_THREAD_INIT; static struct async_lib request; @@ -83,7 +87,7 @@ static void *swupdate_async_thread(void *data) } out: - handle = 0; + running = ASYNC_THREAD_DONE; if (rq->end) rq->end((RECOVERY_STATUS)swupdate_result); @@ -95,20 +99,21 @@ static void *swupdate_async_thread(void *data) * to let build the ipc library without * linking pctl code */ -static pthread_t start_ipc_thread(void *(* start_routine) (void *), void *arg) +static void start_ipc_thread(void *(* start_routine) (void *), void *arg) { int ret; - pthread_t id; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - ret = pthread_create(&id, &attr, start_routine, arg); + ret = pthread_create(&async_thread_id, &attr, start_routine, arg); if (ret) { - return -1; + perror("ipc thread creation failed"); + return; } - return id; + + running = ASYNC_THREAD_RUNNING; } /* @@ -121,8 +126,16 @@ int swupdate_async_start(writedata wr_func, getstatus status_func, struct async_lib *rq; int connfd; - if (handle) + switch (running) { + case ASYNC_THREAD_INIT: + break; + case ASYNC_THREAD_DONE: + pthread_join(async_thread_id, NULL); + running = ASYNC_THREAD_INIT; + break; + default: return -EBUSY; + } rq = get_request(); @@ -137,11 +150,9 @@ int swupdate_async_start(writedata wr_func, getstatus status_func, rq->connfd = connfd; - async_thread_id = start_ipc_thread(swupdate_async_thread, rq); + start_ipc_thread(swupdate_async_thread, rq); - handle++; - - return handle; + return running != ASYNC_THREAD_INIT; } int swupdate_image_write(char *buf, int size)