public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Andi Kleen <andi@firstfloor.org>
Cc: acme@ghostprotocols.net, linux-kernel@vger.kernel.org,
	Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH] perf, tools: Stop perf stat -p when profiled process exits
Date: Wed, 12 Sep 2012 17:30:39 +0900	[thread overview]
Message-ID: <87bohbabio.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <1347430144-26758-1-git-send-email-andi@firstfloor.org> (Andi Kleen's message of "Tue, 11 Sep 2012 23:09:04 -0700")

Hi Andi,

On Tue, 11 Sep 2012 23:09:04 -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> When counting a process with perf stat -p check if the process died
> and exit collection if yes.

I guess we need something similar for perf record as well.

>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
>  tools/perf/builtin-stat.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 861f0ae..1313bb5 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -536,7 +536,14 @@ static int run_perf_stat(int argc __used, const char **argv)
>  		if (WIFSIGNALED(status))
>  			psignal(WTERMSIG(status), argv[0]);
>  	} else {
> -		while(!done) sleep(1);
> +		char piddir[40];
> +		snprintf(piddir, sizeof piddir, "/proc/%d", atoi(target.pid));
> +
> +		while(!done) {
> +			sleep(1);
> +			if (target.pid && access(piddir, X_OK) < 0 && errno == ENOENT)
> +				break;

The target.pid might have multiple pid's - e.g. perf stat -p 1234,5678

Thanks,
Namhyung

      reply	other threads:[~2012-09-12  8:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-12  6:09 [PATCH] perf, tools: Stop perf stat -p when profiled process exits Andi Kleen
2012-09-12  8:30 ` Namhyung Kim [this message]

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=87bohbabio.fsf@sejong.aot.lge.com \
    --to=namhyung@kernel.org \
    --cc=acme@ghostprotocols.net \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox