From: Andi Kleen <[email protected]> When counting a process with perf stat -p check if the process died and exit collection if yes.
v2: Add more checks, handle non -p again. Handle /proc not there. Signed-off-by: Andi Kleen <[email protected]> --- tools/perf/builtin-stat.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 861f0ae..2e5b4b3 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -536,7 +536,15 @@ 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]; + if (target.pid && access("/proc", X_OK) == 0) + snprintf(piddir, sizeof piddir, "/proc/%d", atoi(target.pid)); + + while(!done) { + sleep(1); + if (target.pid && access(piddir, X_OK) < 0 && errno == ENOENT) + break; + } } t1 = rdclock(); -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

