All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Clark <james.clark@arm.com>
To: Leo Yan <leo.yan@linaro.org>
Cc: acme@kernel.org, leo.yan@linaro.com,
	linux-perf-users@vger.kernel.org,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] perf tests: Improve temp file cleanup in test_arm_coresight.sh
Date: Wed, 22 Sep 2021 17:49:55 +0100	[thread overview]
Message-ID: <85c593b5-5348-8e9a-b9e4-bc4d31ffc785@arm.com> (raw)
In-Reply-To: <20210922140832.GB400258@leoy-ThinkPad-X240s>



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
> 

  reply	other threads:[~2021-09-22 16:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 13:10 [PATCH 1/3] perf tests: Fix record+script_probe_vfs_getname.sh /tmp cleanup James Clark
2021-09-21 13:10 ` [PATCH 2/3] perf tests: Fix trace+probe_vfs_getname.sh " James Clark
2021-09-21 13:10 ` [PATCH 3/3] perf tests: Improve temp file cleanup in test_arm_coresight.sh James Clark
2021-09-22  6:10   ` Ian Rogers
2021-09-22 11:00   ` Leo Yan
2021-09-22 13:40     ` James Clark
2021-09-22 14:08       ` Leo Yan
2021-09-22 16:49         ` James Clark [this message]
2021-09-23  1:18           ` Leo Yan
     [not found] ` <CAP-5=fU_CSPv2Kry6ObbfYG4rNJpprhBrFUOJsNugM-AqQ3xoA@mail.gmail.com>
2021-10-26 14:18   ` [PATCH 1/3] perf tests: Fix record+script_probe_vfs_getname.sh /tmp cleanup Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85c593b5-5348-8e9a-b9e4-bc4d31ffc785@arm.com \
    --to=james.clark@arm.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=leo.yan@linaro.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.