[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1546501245-4512-1-git-send-email-yao.jin@linux.intel.com>
Date: Thu, 3 Jan 2019 15:40:45 +0800
From: Jin Yao <yao.jin@...ux.intel.com>
To: acme@...nel.org, jolsa@...nel.org, peterz@...radead.org,
mingo@...hat.com, alexander.shishkin@...ux.intel.com
Cc: Linux-kernel@...r.kernel.org, ak@...ux.intel.com,
kan.liang@...el.com, yao.jin@...el.com,
Jin Yao <yao.jin@...ux.intel.com>
Subject: [PATCH] perf stat: Fix endless wait for child process
We hit a perf stat issue by using following script.
#!/bin/bash
sleep 1000 &
exec perf stat -a -e cycles -I1000 -- sleep 5
Since "perf stat" is launched by exec, so the "sleep 1000" would be
the child process of "perf stat". The wait4() will not return because
it's waiting for the child process "sleep 1000" to be end. So perf
stat doesn't return even 5s passed.
This patch lets the perf stat return when the specified child process
is end (in this case, specified child process is "sleep 5").
Signed-off-by: Jin Yao <yao.jin@...ux.intel.com>
---
tools/perf/builtin-stat.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1410d66..63a3afc 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -561,7 +561,8 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
break;
}
}
- wait4(child_pid, &status, 0, &stat_config.ru_data);
+ if (child_pid != -1)
+ wait4(child_pid, &status, 0, &stat_config.ru_data);
if (workload_exec_errno) {
const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg));
--
2.7.4
Powered by blists - more mailing lists