Re: [PATCH v2 1/2] perf record: Propagate exit status of a command line workload

From: Namhyung Kim
Date: Wed Apr 23 2014 - 10:39:21 EST


Hi Stephane,

2014-04-23 (ì), 14:11 +0200, Stephane Eranian:
> On Wed, Apr 23, 2014 at 8:40 AM, Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> > +out_child:
> > + if (forks) {
> > + int exit_status;
> >
> > - return 0;
> > + if (!child_finished)
> > + kill(rec->evlist->workload.pid, SIGTERM);
> > +
> > + wait(&exit_status);
> > +
> > + if (err < 0)
> Not quite this. Although this works with my test case with 'false'.
> It fails when I tried the opposite test case:
>
> $ perf record true && echo yes || echo no
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.013 MB perf.data (~589 samples) ]
> no
>
> The return code in this case is 255. I tracked it down to err being last set
> by poll() which got interrupted by SIGCHLD. So I think the err value must
> be overridden somehow in this case. Maybe something like:
>
> err = poll(evsel_list->pollfd, evsel_list->nr_fds, -1);
> if (err < 0 && errno == EINTR && forks && done)
> err = 0;

Hmm.. just checking "err < 0 && errno == EINTR" isn't enough?

And I guess the same problem can be occurred during record__mmap_read()
as it calls record__write() which eventually calls ion() and it seems
not to handle the above case.. I'll cook a patch for it too.

Thanks,
Namhyung



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/