Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp651869pxb; Wed, 22 Sep 2021 09:52:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6WEJLbLtq+5t4lz7H4oIiStGMpPC4nkLaWSPpaN7ZWsPA5YrQdtLIqDYBJW3LObzJEQ+q X-Received: by 2002:a05:6402:b23:: with SMTP id bo3mr265451edb.145.1632329523777; Wed, 22 Sep 2021 09:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632329523; cv=none; d=google.com; s=arc-20160816; b=NrKkmQz/3wsOvb6xmlkqnlH7zfCE5rbJcqbTGOuJk5Ds2eblIPNJQvBCiAZwUBlKnk efiOKDN3UtVwylTOIxmYJIF2hQGz5mFimfJWUvws62qmRZnGO4POPYIJKU2a0aDaE3F6 cwY2VHPNqGinXKvIi26OUC5XGdNKUV7zajQWz3rauQrFgWarJlOvX2LMEHWW7e0fPT1o YO4lemlY9C6Akm1WMyNojIdlIH5jVMMq4DjE6Ja4hSeCKg0MbFtctEMsrSeTLXk5xa16 Vj2gr4aGV3xk7xtIMPTMqewqZm6U4BFW6oEqN5DmV6oZk1ZQIBkGrtM3BxUnouApJQBK yDsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=Q9MOTCa4EPV7yDuRDLBF3bq3Hq7QmDHbSct8MH9RL1g=; b=J8kUTie4lRKgx9HOvH5ae3t8eCPJ4fM26C0vNBYQwz6t7W7PmgRg3p4laLSJ4VYCYc SIa2Ph6dfa0aTGRRYA5QetLwFkWLNrnICDyenN7hT5/ZAxFwzs0sKAvIoLyvOPHlTMpY jrESs/lmnlhIYA3zWOwgrfSX41x2v24QQEwegt6k4OwMP69n0sedeGre3qO6zM1T8rfT pHieahr91tGVKlIR1o35GCBFpLekQRT4eDXNgC6Fd2xn3OIb4t8zk6cLMysWUPu/uWeo dYnkNdn35bVuu4uuYGLPQcxbLTcvLxC8kgT7JhR4Z3IpBIIJdv76CJ3Dd6VLqmV0hDWs HhAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g24si3518352edr.84.2021.09.22.09.51.25; Wed, 22 Sep 2021 09:52:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232934AbhIVQv3 (ORCPT + 99 others); Wed, 22 Sep 2021 12:51:29 -0400 Received: from foss.arm.com ([217.140.110.172]:51582 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231925AbhIVQv2 (ORCPT ); Wed, 22 Sep 2021 12:51:28 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 13595113E; Wed, 22 Sep 2021 09:49:58 -0700 (PDT) Received: from [10.57.50.100] (unknown [10.57.50.100]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C86E83F719; Wed, 22 Sep 2021 09:49:56 -0700 (PDT) Subject: Re: [PATCH 3/3] perf tests: Improve temp file cleanup in test_arm_coresight.sh To: Leo Yan Cc: acme@kernel.org, leo.yan@linaro.com, linux-perf-users@vger.kernel.org, Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org References: <20210921131009.390810-1-james.clark@arm.com> <20210921131009.390810-3-james.clark@arm.com> <20210922110012.GA400258@leoy-ThinkPad-X240s> <5a1c5eab-d9b7-5623-2d7d-c6b1921b3628@arm.com> <20210922140832.GB400258@leoy-ThinkPad-X240s> From: James Clark Message-ID: <85c593b5-5348-8e9a-b9e4-bc4d31ffc785@arm.com> Date: Wed, 22 Sep 2021 17:49:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210922140832.GB400258@leoy-ThinkPad-X240s> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/09/2021 15:08, Leo Yan wrote: > Hi James, > > On Wed, Sep 22, 2021 at 02:40:54PM +0100, James Clark wrote: > > [...] > >>>> cleanup_files() >>>> { >>>> rm -f ${perfdata} >>>> rm -f ${file} >>>> + rm -f "${perfdata}.old" >>>> + trap - exit term int >>>> + kill -2 $$ >>> >>> Here it always sends signal SIGINT to current PID with $$, another >>> choice is to send signal based on the incoming signal type, like below: >>> >>> [[ "$1" = "int" ]] || kill -SIGINT $$ >>> [[ "$1" = "term" ]] || kill -SIGTERM $$ >> >> Yes I thought that this might be an issue, but I tested it in a few different >> scenarios. Especially when running it under the normal ./perf test command and >> it didn't seem to cause an issue whether it passed or failed. So I'm not sure >> if it's worth changing or not. Maybe it is in case it gets copy pasted into >> another shell test? > > I think it's not very necessary to send signal again with command > "kill -2 $$" at here. > > "kill -2 $$" sends the signal to the shell process itself rather than > propagating signal to its parent process. And the up level's script > should can detect an error with the returned exit code. > > So below change should be sufficient? > > cleanup_files() > { > rm -f ${perfdata} > rm -f ${file} > + rm -f "${perfdata}.old" > + exit $glb_err > } > > Sorry if I miss anything at here and cause noise. The problem with not re-sending the sigint is that if you want to run the script in a bash while loop like: while ! tests/shell/test_arm_coresight.sh; do echo loop; done Then it's impossible to exit with Ctrl-C and delete the temp files at the same time. It exits if we don't trap sigint like it is at the moment, but then it leaves the temporary files. This change is so we can have both behaviours of Ctrl-C in a loop and keep the cleanup working. > > Thanks, > Leo >