lkml.org 
[lkml]   [2014]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v3 2/3] perf record: Propagate exit status of a command line workload
On Thu, Apr 24, 2014 at 10:27:33PM +0900, Namhyung Kim wrote:

SNIP

> - rec->bytes_written / 24);
> +out_child:
> + if (forks) {
> + int exit_status;
>
> - return 0;
> + if (!child_finished)
> + kill(rec->evlist->workload.pid, SIGTERM);

also while at it.. do we want to force SIGKILL in case we dont
get any response for SIGTERM? so we dont get record hanging like
for following program:

---
#include <signal.h>

static void sig_handler(int sig)
{
}

int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);

while (1) {}

return 0;
}
---

the change would go into separate patch of course,
something like in patch below

thanks,
jirka


---
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 526edf5..a973ba5 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -479,9 +479,20 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
out_child:
if (forks) {
int exit_status;
+ int zleep = 0;
+
+ while (!child_finished) {
+ if (!zleep)
+ kill(rec->evlist->workload.pid, SIGTERM);
+ if (zleep == 2000) {
+ pr_info("Child killed by SIGKILL.\n");
+ kill(rec->evlist->workload.pid, SIGKILL);
+ break;
+ }

- if (!child_finished)
- kill(rec->evlist->workload.pid, SIGTERM);
+ usleep(1000);
+ zleep++;
+ }

wait(&exit_status);


\
 
 \ /
  Last update: 2014-04-29 14:01    [W:0.096 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site