Messages in this thread Patch in this message | | | Date | Tue, 29 Apr 2014 13:15:51 +0200 | From | Jiri Olsa <> | Subject | Re: [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);
| |