lkml.org 
[lkml]   [2021]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] perf test: Cleanup daemon if test is interrupted.
On Thu, Mar 11, 2021 at 08:18:27AM -0800, Ian Rogers wrote:
> On Thu, Mar 11, 2021 at 2:38 AM Jiri Olsa <jolsa@redhat.com> wrote:
> >
> > On Wed, Mar 10, 2021 at 12:41:17PM -0800, Ian Rogers wrote:
> > > Reorder daemon_start and daemon_exit as the trap handler is added in
> > > daemon_start referencing daemon_exit.
> >
> > makes sense, minor comments below
> >
> > >
> > > Signed-off-by: Ian Rogers <irogers@google.com>
> > > ---
> > > tools/perf/tests/shell/daemon.sh | 34 +++++++++++++++++++-------------
> > > 1 file changed, 20 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/tools/perf/tests/shell/daemon.sh b/tools/perf/tests/shell/daemon.sh
> > > index 66ad56b4e0a5..a02cedc76de6 100755
> > > --- a/tools/perf/tests/shell/daemon.sh
> > > +++ b/tools/perf/tests/shell/daemon.sh
> > > @@ -98,6 +98,23 @@ check_line_other()
> > > fi
> > > }
> > >
> > > +daemon_exit()
> > > +{
> > > + local config=$1
> > > +
> > > + local line=`perf daemon --config ${config} -x: | head -1`
> > > + local pid=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $1 }'`
> > > +
> > > + # Reset trap handler.
> > > + trap - SIGINT SIGTERM
> >
> > please keep the 'tabs' in here
> >
> > > +
> > > + # stop daemon
> > > + perf daemon stop --config ${config}
> > > +
> > > + # ... and wait for the pid to go away
> > > + tail --pid=${pid} -f /dev/null
> > > +}
> > > +
> > > daemon_start()
> > > {
> > > local config=$1
> > > @@ -105,6 +122,9 @@ daemon_start()
> > >
> > > perf daemon start --config ${config}
> > >
> > > + # Clean up daemon if interrupted.
> > > + trap "daemon_exit ${config}; exit 4" SIGINT SIGTERM
> >
> > ditto, plus let's document exit values somewhere in comments,
> > I think the next patch is adding exit 62, so that one as well
>
> Thanks, it might be easier to just have these as exit 1 - I pulled
> values from the errno list. Do you have any preferences?

yep, exit 1 seems enough

jirka

\
 
 \ /
  Last update: 2021-03-11 20:05    [W:0.063 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site