lkml.org 
[lkml]   [2021]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 05/24] perf daemon: Add client socket support
On Wed, Feb 03, 2021 at 06:05:47PM -0300, Arnaldo Carvalho de Melo wrote:

SNIP

>
> close fd
>
> > + return -1;
> > + }
> > +
> > + return fd;
> > +}
> > +
> > static void daemon__free(struct daemon *daemon)
> > {
> > free(daemon->config_real);
> > @@ -211,6 +282,40 @@ static int __cmd_start(struct daemon *daemon, struct option parent_options[],
> > return err;
> > }
> >
> > +__maybe_unused
> > +static int send_cmd(struct daemon *daemon, union cmd *cmd)
> > +{
> > + char *line = NULL;
> > + size_t len = 0;
> > + ssize_t nread;
> > + FILE *in;
> > + int fd;
> > +
> > + if (setup_client_config(daemon))
> > + return -1;
> > +
> > + fd = setup_client_socket(daemon);
> > + if (fd < 0)
> > + return -1;
> > +
> > + if (sizeof(*cmd) != write(fd, cmd, sizeof(*cmd)))
>
> close fd
>
> > + return -1;
> > +
> > + in = fdopen(fd, "r");
> > + if (!in) {
> > + perror("failed: fdopen");
>
> close fd

ah right, thanks

jirka

>
> > + return -1;
> > + }
> > +
> > + while ((nread = getline(&line, &len, in)) != -1) {
> > + fwrite(line, nread, 1, stdout);
> > + fflush(stdout);
> > + }
> > +
> > + fclose(in);
> > + return 0;
> > +}
> > +
> > int cmd_daemon(int argc, const char **argv)
> > {
> > struct option daemon_options[] = {
> > --
> > 2.29.2
> >
>
> --
>
> - Arnaldo
>

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