lkml.org 
[lkml]   [2021]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 08/24] perf daemon: Add background support
On Wed, Feb 03, 2021 at 06:16:11PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Sun, Jan 31, 2021 at 12:48:40AM +0100, Jiri Olsa escreveu:
> > Adding support to put daemon process in the background.
> >
> > It's now enabled by default and -f option is added to
> > keep daemon process on the console for debugging.
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> > tools/perf/builtin-daemon.c | 66 +++++++++++++++++++++++++++++++++++--
> > 1 file changed, 63 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c
> > index d0a0a998e073..324666058842 100644
> > --- a/tools/perf/builtin-daemon.c
> > +++ b/tools/perf/builtin-daemon.c
> > @@ -488,6 +488,13 @@ static void daemon__kill(struct daemon *daemon)
> > daemon__signal(daemon, SIGTERM);
> > }
> >
> > +static void __daemon__free(struct daemon *daemon)
> > +{
> > + free(daemon->config_real);
> > + free(daemon->config_base);
> > + free(daemon->base);
> > +}
>
> Please use zfree(), and also please rename it to __daemon__delete(), in
> other cases this pattern would be daemon__exit(), as the daemon
> structure itself is not being freed, just its members, ditto for
> foo__new() calling foo__init().

ok, will change

SNIP

> > static int __cmd_start(struct daemon *daemon, struct option parent_options[],
> > int argc, const char **argv)
> > {
> > + bool foreground = false;
> > struct option start_options[] = {
> > + OPT_BOOLEAN('f', "foreground", &foreground, "stay on console"),
>
>
> You forgot to add the entry to the man page

it's in the man page patch later in the patchset

thanks,
jirka

>
> > OPT_PARENT(parent_options),
> > OPT_END()
> > };
> > @@ -667,6 +716,17 @@ static int __cmd_start(struct daemon *daemon, struct option parent_options[],
> > if (setup_server_config(daemon))
> > return -1;
> >
> > + if (!foreground) {
> > + err = go_background(daemon);
> > + if (err) {
> > + /* original process, exit normally */
> > + if (err == 1)
> > + err = 0;
> > + __daemon__free(daemon);
> > + return err;
> > + }
> > + }
> > +
> > debug_set_file(daemon->out);
> > debug_set_display_time(true);
> >
> > --
> > 2.29.2
> >
>
> --
>
> - Arnaldo
>

\
 
 \ /
  Last update: 2021-02-04 20:33    [W:0.138 / U:0.460 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site