From patchwork Fri Nov 19 09:04:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1556999 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=FUPc1x3+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::43e; helo=mail-pf1-x43e.google.com; envelope-from=swupdate+bncbcwivbv7sugrbb6r3wgamgqexxrdewq@googlegroups.com; receiver=) Received: from mail-pf1-x43e.google.com (mail-pf1-x43e.google.com [IPv6:2607:f8b0:4864:20::43e]) (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 4HwW1n0vdGz9sRR for ; Fri, 19 Nov 2021 20:04:11 +1100 (AEDT) Received: by mail-pf1-x43e.google.com with SMTP id e7-20020aa798c7000000b004a254db7946sf5284211pfm.17 for ; Fri, 19 Nov 2021 01:04:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1637312648; cv=pass; d=google.com; s=arc-20160816; b=nEDxGDLQY43RXq89Vxe4sGpbZecc7iTVJ3De+hlNO0fnQ6EAEoxBVJa3GmfI9sdhPV y6aiHar+VOBHzka0PSIMF/0k/9SctFQ+t+pQpauFmWol2j5RQ41B+2vQOgsT3LkYqGbk f4FzlZrDPT1SlHMhpDXolYpCSVgs8ZpM91qyhG8cAxOnlaIf5SD8UgFtXsyW8m0youQt Q3w338btGeRkekQ8ZJ7O3TVaioOnoaYVlapkM2HJPd2CuaJGU3zjB5c8TUS5Vq3weChP 28kEay/bIxigmM11GRGDcZ25+EVNg3VN9tpU8QPWgwtWaILPFsajfPII2T76XejcYNq3 fhmA== 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=Hzs+gxJivHaxL1IFINcr2I7i87CtHaLISwOgX65AJBc=; b=heR3TghrWPC/ivBZ3QvPREQIB5KpsGX+rpreLFNjeC98kCKEnzFbRvH30oKLQsbxiw gFI0EdjMpfshmB+KIEDksjyEfaP2yekPk9d31hPx9fvuTDedW0xm0GexjegAtlI5zCBt NqnlyrE6PZaOeyWZaot66ubZk6PF7QjT+OANRoCYmKKGCpWiq5ECq/pxXSTZnFyiVut+ 6FaXum8/ChS0L92xeF2SQePfvplJZKSgzUD7pyI2vzRJ+dfkKbSEjtWZ7gZqEKOHIkQY R8/RnAZL/g/ayvWXTUgs2NOChy20Dx5vCoRgnGR/mtJSt1MYVp7DP+sik+SigcoGO5g0 vJzg== 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=Hzs+gxJivHaxL1IFINcr2I7i87CtHaLISwOgX65AJBc=; b=FUPc1x3+MWZzF2QcPnFRMXgoJx6PG49OyAipn9vaL5+ckn1tzV0ouFhY8UHpM0VZXR v1WV2o5AbpyDwxcUYQyQqoiwbaoy0mUzvrFxtf0r+VYY75h1UDHHQ4gnDfPtt+n79lHX pfVY0UGSlakpGBw5flkL5NVk5xI/Mf/UHPD0L4pVQtgVrXupvIBPAzZrfT3vWR0mev7G HsU049mf8aBYuCUYiO0s1E2xgb1T82/4+kpYrUM4RqBo0lkYtBBwCg9aPsaY0Z3GAMc/ uOX6GRaPZoJhDU14GWbltUDSJsybza357g6czhKguL157XcKXA23dale15Al1UHIZOYh SMWg== 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=Hzs+gxJivHaxL1IFINcr2I7i87CtHaLISwOgX65AJBc=; b=nJufxLR9rXyJrBQ1w/PxqPxEPO/AQ+2zXKJTb+ek2XcQs5WObXjuUXRQXJZo7fhmIQ sQffB/zEV9NYmLBfipmalzS7EVgRQKCXaWGWfQC0Qa69fQnIdyh0lcErDE28/yqu7Ly/ 4sj7VEN8CWIbKBLiOiqvN366Sf1ihOk7fLMHbbmw49CM0DwA5rvW6GP0ZKMoA2rEfg8x JCmM9ySARQhwAtcy/2pboFlVtIDSrYCOLy0VnXvDVeQUTgwaIEgqmbzavp4s9AHQGzaR ciYT1aURTLQgwXC/a4PezdIkEO1l6s9bD8KnW0AII9XUhILaX3nidCc21Dqcc3czQnr4 +Y+w== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530/lSmUdHvKIvq6ZEXMPpA964CU2a7ViibVS8NQFqffk2iFwJ9h XYg8IMVZSw0KdrU3O+5tquE= X-Google-Smtp-Source: ABdhPJx9fGlW3/7RPOn+2cPnE4sxJgl/NrcYuAz9A/4jMJq7ss3u/ETJxRXG58gcNNyCnv9uSf6bcw== X-Received: by 2002:a17:902:6905:b0:142:9e19:702e with SMTP id j5-20020a170902690500b001429e19702emr76150538plk.34.1637312648188; Fri, 19 Nov 2021 01:04:08 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a63:194d:: with SMTP id 13ls622653pgz.5.gmail; Fri, 19 Nov 2021 01:04:07 -0800 (PST) X-Received: by 2002:a62:9215:0:b0:49f:e38b:d043 with SMTP id o21-20020a629215000000b0049fe38bd043mr21424276pfd.86.1637312647253; Fri, 19 Nov 2021 01:04:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637312647; cv=none; d=google.com; s=arc-20160816; b=qNvBL04xMdD3pJb6fbag8yu4zlE1HIhRFQEuA8XEWGOkJZT5p9LMevXeq4xbs3+xJt njYruPJSc45ezrJ9rrLQl6BQeB6Y97Puz0QWk8npCIWrDljJq3EcAVGdZI/jCo8ZEbMX RpGUxnApAiLpwquU+8Q3Rt0Nc1FV+9tesdVgNAgPbprtMCi84BP9cZS7vp35SXHqDonI YFpj0+lClmQSxo+Ua2pHNikE+xsl5G35FM1m0FVgLTyt/oZJDlImCbBzZvHwVYSB5F5B OwRGBJJGHlqLg6egYQyb/mSO+wJAsNkr6dpRptRd2m3J7uF45sgU6bdw2MQhtvkxjRc0 gQwg== 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=KZNcX2S8I1cFlIQjgoH4Bhp8ZK7tRlHF0M/2BEfWwXM=; b=hY2/+qjv+oLHLFom9UxfiyUVudvrthxVN1bKNISkBm5DYEfu9PuMK9MGxOXwLaohvP 7ASeJf60CcUs8mVimh+C4rB4lmVJ0N2o3QnWR5D4BgdCVhZrn8Vdlg6T+128NDVwLs7e VO83lz0or0+8KI+oRbfY4kIod9rLgdlONhD1LjVzhsGW/HIL5zKPAFl73CISBI6ZNXAZ IArbhqMlAo+Y8o7AEEz66dY8Ubot2xiflTDpRL8Kl/LOjIm9urS1PCKBk7BH+X8rynek XWUUjv6n0h64Ik9NjNLKoUy6cEAD0yWnOU/NHrTXSB+QySuh+X7hGliloAY7xiOF4wzn 9HRg== 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 s24si85856pjp.0.2021.11.19.01.04.07 for ; Fri, 19 Nov 2021 01:04:07 -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 279ED20D5D for ; Fri, 19 Nov 2021 18:04:06 +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 0837020D5D for ; Fri, 19 Nov 2021 18:04:06 +0900 (JST) Received: by mail-pg1-f199.google.com with SMTP id r15-20020a63ec4f000000b002e582189837so3924349pgj.20 for ; Fri, 19 Nov 2021 01:04:05 -0800 (PST) X-Received: by 2002:a17:903:41c1:b0:141:f28f:729e with SMTP id u1-20020a17090341c100b00141f28f729emr73929746ple.34.1637312645144; Fri, 19 Nov 2021 01:04:05 -0800 (PST) X-Received: by 2002:a17:903:41c1:b0:141:f28f:729e with SMTP id u1-20020a17090341c100b00141f28f729emr73929718ple.34.1637312644920; Fri, 19 Nov 2021 01:04:04 -0800 (PST) Received: from pc-0115 (178.101.200.35.bc.googleusercontent.com. [35.200.101.178]) by smtp.gmail.com with ESMTPSA id l11sm2066278pfu.129.2021.11.19.01.04.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Nov 2021 01:04:04 -0800 (PST) Received: from martinet by pc-0115 with local (Exim 4.94.2) (envelope-from ) id 1mnzoR-002n0s-FI; Fri, 19 Nov 2021 18:04:03 +0900 From: Dominique Martinet To: swupdate@googlegroups.com Cc: Dominique Martinet Subject: [swupdate] [PATCH 2/3] run_system_cmd: do not consider command over if child stopped Date: Fri, 19 Nov 2021 18:04:00 +0900 Message-Id: <20211119090401.664993-2-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211119090401.664993-1-dominique.martinet@atmark-techno.com> References: <20211119090401.664993-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 --- Note: sigchld_handler does check WIFSTOPPED/WIFCONTINUED without setting WUNTRACED/WCONTINUED flags to waitpid, so these should never match in theory and could be removed 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; } }