From patchwork Tue Jun 16 08:34:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1310131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::340; helo=mail-wm1-x340.google.com; envelope-from=swupdate+bncbcxploxj6ikrbl4iul3qkgqedpjmkci@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=NvDDEeEC; dkim-atps=neutral Received: from mail-wm1-x340.google.com (mail-wm1-x340.google.com [IPv6:2a00:1450:4864:20::340]) (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 ozlabs.org (Postfix) with ESMTPS id 49mM2Y3PVPz9sRN for ; Tue, 16 Jun 2020 18:35:00 +1000 (AEST) Received: by mail-wm1-x340.google.com with SMTP id a7sf662947wmf.1 for ; Tue, 16 Jun 2020 01:34:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1592296495; cv=pass; d=google.com; s=arc-20160816; b=KCMnM4AnosxjEciFaLRwCptBwcFpcCfVDu/CYRJSSOlVp5ZRjlPSsNOL8OTzeeGukX PLORErHZQ8qX68cxYBnN6dFw3RIfyLPN1DT8ovalA7NCg7mxIJHVQH8qoGb321iItXi+ E31I8C2VhNyb0F++gbiN369/PhO53hJVzo5En6Y9JCaeChMC0esS/2qBtPxSHMb1OcQf a8GLc3oAb8sCE2nbljcu1p540cyrjRGrbtTNDSHGmQ2Vtegc6bpQnxF0rLoD+g51rGod jeF3lzFBp5oYPpauO6Xrogrs9qzXlXoM1Iu3NQVaXEOYY3kTrZdW0UzPUBdIC8is05jy Tgkw== 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=gk4BTVUuHLs8rHjm5oSFtMV1mtLr71uB08aTcIqhu1w=; b=E+wKWqx6zo1AIFpfs2hhr+mUiSlJf3e1+cZPgkqcRhO8YJcZnv15aVHLHrTjEDFPMZ giHl/ENZdKPtV937cf9QwZs8kYcOwLP2qvyugyb2h4XRMbXXa/EZbdL1IkxeaWpRxMPH spCbyAoqFItZYNADNOrVrPDRooVBme03ierYeu+yaefolRyxmswLavTYP6OzpOF8ifdH QFqx3yrYn5yy92E0Xa3AGhw1FRULxz9TwA5Q13mgr1y8V3wbU/Bkt9aS4nJDJ7X/ZiW9 wsx0wugn+kBADOppp/2+liqrukMUVi4R3eXYRFf2qkvj+nwm1oJqfsEBq8E30Pmag34P 3X3w== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; 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=gk4BTVUuHLs8rHjm5oSFtMV1mtLr71uB08aTcIqhu1w=; b=NvDDEeECaL3dK98cMrd6PkDQ0C6ihUw8Uyf9Xb+khUnP670Ce9PnB5EXPQmoEVvRJr BJ34VZ0uN6i/R86Ab+CJIQDTpHSffD6TJsGHCuMdymLefg3l/5FGlHgfqWmiIcEfO2gJ ujRRmsoxGANKrlexQ1QAfkLCyi1nVF/jKBYQtSdlUfQnsgunzjPtOfTIWt4D00N+5O17 2G9lnArRVSIbYXY8CC0V1nrcsKfNztK4p5BTQ8q1/knlJVfW3NWIZgD8VZ4lgLwqT4Mx BX65sFOaMfnwP7Uwcv7Drhgb9YCM3NKpaFYp1d8AykwY80jBz4Xb8J6yuu+aFXlmBw/g hrxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=gk4BTVUuHLs8rHjm5oSFtMV1mtLr71uB08aTcIqhu1w=; b=GhfZuv0p1zvT0pXAE4fnOQaS7BTQGa7BNMpM0Oewgc6VhwJrghuZwojDz71Eol+2h3 Fk2X0xYPWcqP4VVrRuFOkDbMnUND/XeNKi37fl6k32h1oWGWHz1BjciqW6202Uf6aeaH m1dS+3VnTc7+y1JlAonFDOUzo6wI7eu9jnMrkIpiQLqz//JCN3SVSDDWItsS1ZJaI6cz AebwVWIXOIEMnxij7V0Xbxtc8VVXCjo3P14Mpoc+dKdecOe3062GadseNoc99cVTKFt4 os05oWWdoh8G257uy1xujj4w+watPFzHIUu1nXF5g/xIGJav5pU7nBjn7XVhFplD16Un orNA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531b6AXv8QP3fuNhQ0PG7TYN7KVZ++PmrJB66NwE/V+fHycgELqn 6AumDDj26k9fnu+eGXXkVEE= X-Google-Smtp-Source: ABdhPJziSnYkTWaxIDG1Z6/mfOppgBDVPza9xnZUFlIde+BsgyYIqbyydsKBuxHAx1rTYC/n4UKGrQ== X-Received: by 2002:a1c:38c2:: with SMTP id f185mr2076106wma.79.1592296495669; Tue, 16 Jun 2020 01:34:55 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a1c:a70e:: with SMTP id q14ls1013550wme.0.gmail; Tue, 16 Jun 2020 01:34:55 -0700 (PDT) X-Received: by 2002:a7b:c18a:: with SMTP id y10mr2107082wmi.73.1592296495021; Tue, 16 Jun 2020 01:34:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592296495; cv=none; d=google.com; s=arc-20160816; b=BYGwIdfLadh4XoFLTEUbnH8Vhhtbz/S0Ht690RI9wJ97yhiXprCN6+6+TdFacFSE2p lGm/ue/hfM+dihUKQKCMi7IbPPJdPDphAHM/92x8cpH6DCs/1LTfsKtBiF/8vHEvHUi0 yX0X03wsiLgyepvpKeXuA18w1mrfcOovSpxXCGcpxoUtvDVd3d03OXB3BbJLSB85qNhY tUEw4CwqE6xIbkMR5YDkcMyedqwg3HZ49F02WjLkkmWEr1UDVb85Zt0zV0k4vR4inIHJ SwBuO6KeJRxEWEN/JZ/Kyx9cmmiR2l+VS1gCgWJRTHXtLNGsqr5l1fhBgvW+e6yLw4+o zMbA== 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=gafYWsVK0vEgN2Zy6vcEmpYE2KrhZXIF/6rp3xLJMhw=; b=IXFKDMvIJFeZR+NsywHiVE5HklQZt9/s1wYSIiZD13akwa4hHXuIfNaCvD5K7ToieO NG9I7mvp8aq3Qr+q7m4V3rrxOgb5XNXUUaz8RWn6ijGPpSQf+mg+ByCHTAS3C+ztSdoL vemcYQ+qdIJfnGMKb9sVsDN+IMI9qT+9jX1d4rZgppA1B9tYT96l2RdessZzGRqPgSnC Kv8uJCYAVcHZeYHeCbdOSFWRY3PB5hvGXeYfnR1AAnp6XgBqwcgq5A3xXdwppn88vshI CT9k8yiemT+0svQRrbsPj5xO+t92sA2RHqbrqgwn/fRv+zjt1Z/w7z1nABbDvUHb00mZ r4xw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id m16si146782wmg.2.2020.06.16.01.34.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jun 2020 01:34:54 -0700 (PDT) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 49mM2Q5Hj2z1qt46; Tue, 16 Jun 2020 10:34:54 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 49mM2Q4tBLz1sPNT; Tue, 16 Jun 2020 10:34:54 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 5WRIc2jU-a7u; Tue, 16 Jun 2020 10:34:52 +0200 (CEST) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Tue, 16 Jun 2020 10:34:52 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 6719945404DA; Tue, 16 Jun 2020 10:34:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Vl4ajIYgSVbK; Tue, 16 Jun 2020 10:34:50 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id D531245405B0; Tue, 16 Jun 2020 10:34:49 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic , Piotr Piwko Subject: [swupdate] [PATCH] Shellscript stops before completing Date: Tue, 16 Jun 2020 10:34:48 +0200 Message-Id: <20200616083448.1563485-1-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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: , Commit 8fb94d7 reworks the way shell script are called, redirecting stdout and stderr to SWUpdate. A shell script runs then in a child process. Under some circumstances, SWUpdate closes the forked process before the child process completes. Be sure that the child process has terminated before to go on. Signed-off-by: Stefano Babic Reported-by: Piotr Piwko Tested-by: Piotr Piwko --- core/pctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/pctl.c b/core/pctl.c index 8b1c667..01ad540 100644 --- a/core/pctl.c +++ b/core/pctl.c @@ -263,6 +263,7 @@ int run_system_cmd(const char *cmd) } } else { int fds[2]; + pid_t w; close(stdoutpipe[PIPE_WRITE]); close(stderrpipe[PIPE_WRITE]); @@ -276,7 +277,6 @@ int run_system_cmd(const char *cmd) * and from stderr (of the child process) as ERROR */ do { - pid_t w; int n1 = 0; struct timeval tv; fd_set readfds; @@ -373,7 +373,7 @@ int run_system_cmd(const char *cmd) } } } while (ret > 0 && n1 > 0); - } while (!WIFEXITED(wstatus)); + } while (w != process_id); close(stdoutpipe[PIPE_READ]); close(stderrpipe[PIPE_READ]);