Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1587304pxb; Thu, 4 Feb 2021 17:44:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOm8xHfZcwRx8lFxNyjnCQwigIKwUGPbio3j594RdNzj10X2bmdYotyBrz6x4ZH+dt+IXx X-Received: by 2002:a17:906:1d51:: with SMTP id o17mr1789380ejh.85.1612489471213; Thu, 04 Feb 2021 17:44:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612489471; cv=none; d=google.com; s=arc-20160816; b=GoZ5gwLlAKToHwEL0SVJ43fFOag3lXhVbLHP+qsgib+VI3ZQcfCLvCDzPdaGu2eXz+ P3Rcruxx4mVe/cY/VK7Ug8O1lL+8gNbO+w0nYU9aBJ67zattCNcYd1H4GEWmncKcMxyQ oZi+IoDWSbVCvHpU1RdGMst6YmklqF/XDhETAiX6SJs/zjSKqOlGA4WP6yNTFvCDkKpS 3d6nN+HGSfKrqjnq1I2sLNLHtf2mEmef4otosoGzq1gnB3bMT6TI2XFA/MvevAZjlBQJ Yi2d/yZC3fOpStKIlq9RVt4Px/Mg5zMG0fZg7ZhkeSTkS9FM9dBJUsu9cp9Vu166xRtR wNgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=61cY2haHQh/0KR2HuqkGx27VjalgwkcE6qYdpiegMPk=; b=OXwu4U+GQlv0VQG9cOwZbQ9x15hj0iINWD0doxov6ueYti6/adIuBEzwls+wIDuOrp 88OZK+24cuylrizTTqL3z8zeT3T+yO9Ns6Mtr9ya+xoGLiO1+ZJfZKZLaewuxKs5SdVn RnjwlWP7Pby4pgqmDgLQwieDSeIiaD8OPbJS57Q1440fBiTgkOJvfLrDVUoNd/E3HZO2 6adpax8qkgRVNUJNRFNKr4H/eIq1e8ArbA/ebE4XUirgZEmHCgLai9o6I5AGEgXxYCak ZWWH+QT/IiqrS2VnuoUWjAeaAsO2mS2htCPlIoh6tBWUXkLlRIOE/QNlWsOWnJmoRNXH VvzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z7OlDOgv; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si4576339ejg.566.2021.02.04.17.44.07; Thu, 04 Feb 2021 17:44:31 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z7OlDOgv; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239775AbhBDTdW (ORCPT + 99 others); Thu, 4 Feb 2021 14:33:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:23354 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236783AbhBDOwD (ORCPT ); Thu, 4 Feb 2021 09:52:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612450232; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=61cY2haHQh/0KR2HuqkGx27VjalgwkcE6qYdpiegMPk=; b=Z7OlDOgvqlOnTEnuDh1PR062T9GvOKxUKvkx/eyW72KHrk1hesWU5nPmf6Cq1vfl97oVoT QKESMHCTlaT+xX/raQ37UkDz40zTkdBWewQKgrnGvZqSXRpM0zP29zYxsWmdNXE85zA/u+ SEVxHzX9EiwGi7KDbiUC/QEksAMAQto= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-C49vkJ2WOTaouGWEgscxKQ-1; Thu, 04 Feb 2021 09:50:28 -0500 X-MC-Unique: C49vkJ2WOTaouGWEgscxKQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0AC375B399; Thu, 4 Feb 2021 14:50:26 +0000 (UTC) Received: from krava (unknown [10.40.194.33]) by smtp.corp.redhat.com (Postfix) with SMTP id 910EC19708; Thu, 4 Feb 2021 14:50:23 +0000 (UTC) Date: Thu, 4 Feb 2021 15:50:22 +0100 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Ian Rogers , Stephane Eranian , Alexei Budankov Subject: Re: [PATCH 05/24] perf daemon: Add client socket support Message-ID: References: <20210129134855.195810-1-jolsa@redhat.com> <20210130234856.271282-1-jolsa@kernel.org> <20210130234856.271282-6-jolsa@kernel.org> <20210203210547.GR854763@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210203210547.GR854763@kernel.org> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >