From patchwork Mon Nov 22 10:04:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique MARTINET X-Patchwork-Id: 1557941 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=EKqgr7jB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::438; helo=mail-pf1-x438.google.com; envelope-from=swupdate+bncbcwivbv7sugrbq6w5wgamgqeayno7ta@googlegroups.com; receiver=) Received: from mail-pf1-x438.google.com (mail-pf1-x438.google.com [IPv6:2607:f8b0:4864:20::438]) (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 4HyNDR58BDz9sWJ for ; Mon, 22 Nov 2021 21:04:55 +1100 (AEDT) Received: by mail-pf1-x438.google.com with SMTP id 4-20020a621604000000b004a4ab765028sf4739719pfw.13 for ; Mon, 22 Nov 2021 02:04:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1637575493; cv=pass; d=google.com; s=arc-20160816; b=CdYhXin5C395VzBo7wI0TZI+BFR1CIEOapb/JnpMAT6qPRUJT61vVJYeyr8pxso8GJ EAcptQhc1kGSk374yjbjlW+QM/OJBOprBFkh6jxPPrz+/0hMga+XBwnbFHL6/HpmT1fV V6GVNif0U97H/B/vATNtzoAkMmSjCxcA5kWyBfBxx9hiOI1nqIviCIdKSq2KZD1Mb2vo fxKpbmNB5IriXRexZvYSqCo6WULcD7XPGWULMWoHre9nuKjaOT0Q0bbUeaFHNgWN+X/c oGz/sSoE6xJfnkUm9BCwrvvlzrQAnzzcSm1Vy2t8q3ruPJkt/LOMSlwhrF7n9cmHYxEe ILYQ== 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=dFXOvsxNx9nHTD67JrX7W61RE9X70ScS4TbR1Ppz0R4=; b=rP01BU2kS5UBUmHJYgR4u7rK8yffzYsp8kHowplq7m4XWbJ4sqZja5yNM03qE/512b RbfuOUFbVnkar5dKdSvpLyVJICW/PqdsAEdMxawiVTvOfOJEpbB2a0DHY59foh1F/Tax R1L7Vct03xQ/BI9XOZfgkgHjS2oEhoAq8EwpsurzulzKZekL2RjwfWXECHWxCcrZdB7P EVPjf8I6okw2vy0ud7ESt5DJoTjxMcYfsUeJ2xDbjzMSqWCtkHIuOIev9Oi2SjuJ0q5N cNSOYDzBclRVFvNuN7phbDKA7yy47cfWnqVagW1qR/bhUoZU5JdEm06xsvEroSzcZACu cj7g== 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=dFXOvsxNx9nHTD67JrX7W61RE9X70ScS4TbR1Ppz0R4=; b=EKqgr7jB7QkV1hnwVdeRgdRj8I+N3tXSs/a6dkyNMYcA5ewl8CavEW+QTRsP/sqbN6 VGo6LgwYjz8ObMpJcBuBKLn4dqWL5JHkZ/iQzIxr0jmqsdyoTrDw52OrirwP10UIW8up ueY5cYcdFIZBj4ZEgJzI4G/hdqfvfP/VL9v4KXlKoKZZrS1fYpTRV2JwGX1kd0CuK0od bxHjeEP1RqhBlNB/wxQ2FxABnpJNU0UiFIdKeAIMAtIzH0K+M1omJkLxycxrO5cT8XOU Otmkvw44GXGfjDay7BZdBRQjHfVavQQcG+V3SfdrLUyY0KsqUKyP6ZrKGCvzExkVhFxu PADQ== 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=dFXOvsxNx9nHTD67JrX7W61RE9X70ScS4TbR1Ppz0R4=; b=xbJgCQqc/SmnRfljtZngJyJ3nxEsRYxiQDnEznjjl+qtBLQakjyNVc53NMS80sQAQ4 AUQ63nVBZdr3OPpsK2Iss2ASKwLGmfJjrQTaCD4Kv/BDCyZVExC7HmDD90kroGZVVClQ IYPTFEJcycX001KYzsbrTrdOKXEFyVN6AD7b25Jmb0o4WDL95VeraAqIeoGO1rT8Hhzr 627jIfukJCzO8/EtPz/0rTwUXxlR29FZnHi1TPhv7nJrzUJ1cT1eKRwDs3XxQ7XJDH7G XVoJyHZe+u/A5EZJW4Ajm0ICXHAQiVWhbfIB+EtWodrzjaugIV8+qCW2q1rZHINWfqeu 7x5A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531+SU7EFsJnMS6A+mhiOiMaVfMazws1X7ReaMZhxdUobmDequdk ev4AlreOL2iIKZqxGrzov3g= X-Google-Smtp-Source: ABdhPJw9y1brQSBTQ6N+ZU6iW0Y7wLj/14Ch1rJTZxRjSLgV5tRSsCbUwiq4RjdrVEKVwghtFz0igg== X-Received: by 2002:a62:1887:0:b0:44c:872e:27ed with SMTP id 129-20020a621887000000b0044c872e27edmr42730408pfy.71.1637575492156; Mon, 22 Nov 2021 02:04:52 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6a00:a81:: with SMTP id b1ls2561062pfl.3.gmail; Mon, 22 Nov 2021 02:04:51 -0800 (PST) X-Received: by 2002:a05:6a00:1a04:b0:4a0:6e3:27b3 with SMTP id g4-20020a056a001a0400b004a006e327b3mr42817963pfv.24.1637575491472; Mon, 22 Nov 2021 02:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637575491; cv=none; d=google.com; s=arc-20160816; b=B4TOhQeevfhspBtd8i/7bGROw5i92yvXJ/cxQXWIxuuBP1LdNRk4bi/GXRLLyr2Y+p 5uY6U1xhPT20J3Q9eLYymBsNzvwuaXri3I+XjAgqh7ZZW07cxqSMj7ygjZcTicwkzzT6 KsWDQTe8abLmCzWcb1nt19A5oNAT56AyLBKqCz2Ig7K3AmXDFPoLpOSQCm4I6aki7RHb Yf3anMaizE5DYuKdx+tQ34QoFh8Jvitm2yZg8HTPkARrPuxawNQzl/tzBCutQWZwK2vO 8/qyjtHYeTDPbHwPx46/NZUQjZXWzeA4RYmp2mRMiH+vlklcrSwUGsv/E8+tO75cmsfT O5tQ== 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=x6a6YRMFMnlXkNKvYs20hNwIjafekaMgJ8xW2r8AI0E=; b=TLkGh/aA7+B7uhGdKnV1sR07GX9By/k2Ia9ElOtwPhq4Z6FSewy5uPdWiIjQmM/hjq 6icU4FkZQgc533HkjNcMkvQq4kmcwtcdpE8RGMeiGPsqWZf/PG7AikE9/77qLM3FIgdb 00pfijrPmWOj+9gRSuOGI9N1/yXGEbzfnzYjGeZnTP+ty+mrhulfxvIOFrA9JclUHpnZ x44KvKtA7JtYGMUytmm+CfBti2ovSzaxSmqgYoOL/3lcMtUJcg+cvQEiFr4i9o+9xs31 hDga4v9HakWab4gDvXfsjFme09u5DXAX62/O6DWyduOjvkj9wPsiRG+QQEkCin7fMk2c WPrQ== 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 w1si1126206pjn.1.2021.11.22.02.04.51 for ; Mon, 22 Nov 2021 02:04:51 -0800 (PST) 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 3985920D63 for ; Mon, 22 Nov 2021 19:04:50 +0900 (JST) Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 165DE20D63 for ; Mon, 22 Nov 2021 19:04:50 +0900 (JST) Received: by mail-pg1-f199.google.com with SMTP id s18-20020a63ff52000000b00320f169c0aaso1306781pgk.18 for ; Mon, 22 Nov 2021 02:04:50 -0800 (PST) X-Received: by 2002:a17:90a:e7d1:: with SMTP id kb17mr29401050pjb.124.1637575489191; Mon, 22 Nov 2021 02:04:49 -0800 (PST) X-Received: by 2002:a17:90a:e7d1:: with SMTP id kb17mr29401023pjb.124.1637575488996; Mon, 22 Nov 2021 02:04:48 -0800 (PST) Received: from pc-0115 (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id pc10sm7788677pjb.9.2021.11.22.02.04.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 02:04:48 -0800 (PST) Received: from martinet by pc-0115 with local (Exim 4.94.2) (envelope-from ) id 1mp6Br-00BdjV-7r; Mon, 22 Nov 2021 19:04:47 +0900 From: Dominique Martinet To: swupdate@googlegroups.com Cc: Dominique Martinet , Stefano Babic Subject: [swupdate] [PATCH v2 02/10] run_system_cmd: do not consider command over if child stopped Date: Mon, 22 Nov 2021 19:04:35 +0900 Message-Id: <20211122100435.2774211-2-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211122100435.2774211-1-dominique.martinet@atmark-techno.com> References: <20211122031619.2202449-1-dominique.martinet@atmark-techno.com> <20211122100435.2774211-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: , waitpid() with WUNTRACED or WCONTINUED will return the pid if process has been stopped or ptraced, which can lead to swupdate considering the command being run before it actually is if something interacts with it. We don't actually check WIFSTOPPED/WIFCONTINUED below and don't really care about this state: just remove the flags to waitpid() While we are here, only check WTERMSIG() if WIFSIGNALED is true, and add a final neither-stopped-nor-killed state which probably should not see much use Signed-off-by: Dominique Martinet Acked-by: Stefano Babic --- no change from v1 core/pctl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/pctl.c b/core/pctl.c index c31575aa309b..2a09d9807e3a 100644 --- a/core/pctl.c +++ b/core/pctl.c @@ -328,7 +328,7 @@ int run_system_cmd(const char *cmd) fd_set readfds; int n, i; - w = waitpid(process_id, &wstatus, WNOHANG | WUNTRACED | WCONTINUED); + w = waitpid(process_id, &wstatus, WNOHANG); if (w == -1) { ERROR("Error from waitpid() !!"); close(stdoutpipe[PIPE_READ]); @@ -386,9 +386,12 @@ int run_system_cmd(const char *cmd) if (WIFEXITED(wstatus)) { ret = WEXITSTATUS(wstatus); TRACE("%s command returned %d", cmd, ret); - } else { + } else if (WIFSIGNALED(wstatus)) { TRACE("(%s) killed by signal %d\n", cmd, WTERMSIG(wstatus)); ret = -1; + } else { + TRACE("(%s) not exited nor killed!\n", cmd); + ret = -1; } }