From: Peter Zijlstra <peterz@infradead.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Stephane Eranian <eranian@google.com>,
LKML <linux-kernel@vger.kernel.org>,
Namhyung Kim <namhyung.kim@lge.com>
Subject: Re: [PATCH v3 2/3] perf record: Propagate exit status of a command line workload
Date: Wed, 7 May 2014 17:04:04 +0200 [thread overview]
Message-ID: <20140507150404.GO30445@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <87tx9boeaf.fsf@sejong.aot.lge.com>
[-- Attachment #1: Type: text/plain, Size: 2406 bytes --]
On Wed, Apr 30, 2014 at 09:24:08AM +0900, Namhyung Kim wrote:
> Hi Jiri and Peter,
>
> On Tue, 29 Apr 2014 13:37:47 +0200, Jiri Olsa wrote:
> > On Tue, Apr 29, 2014 at 01:19:39PM +0200, Peter Zijlstra wrote:
> >> On Tue, Apr 29, 2014 at 12:56:54PM +0200, Jiri Olsa wrote:
> >> >
> >> > perf_counter tools: Propagate signals properly
> >> > commit f7b7c26e01e51fe46097e11f179dc71ce7950084
> >> > Author: Peter Zijlstra <a.p.zijlstra@chello.nl>
> >> > Date: Wed Jun 10 15:55:59 2009 +0200
> >> >
> >> > but I dont think we need to do that
> >>
> >> But but but, then you're re-introducing that fail again? That no good.
>
> FYI, it's already gone with 804f7ac78803 ("perf record: handle death by
> SIGTERM").
>
> >
> > well, I was trying the testcase you mentioned in the changelog
> > and it seemed to work for me.. ;-) I guess I was lucky to hit
> > the bash time window..
> >
> > while :; do perf stat ./foo ; done
> >
> > so how does this work? bash will kill the loop if perf's wait
> > status is WIFSIGNALED?
>
> I'm not sure but isn't it *bash* to catch signal and terminate the
> loop? It seems the wait status of child has no business with the loop
> termination. Am I missing something?
>
> $ cat suicide.c
> #include <signal.h>
>
> int main(void)
> {
> raise(SIGTERM);
> return 0;
> }
>
SIGTERM isn't the problem. SIGINT is. Typically when you run:
while :; do perf stat ./foo ; done
Its foo that is running, so when you press ^C, you'll SIGINT foo. foo
will then exit, perf stat will notice the exit, exit itself and because
the loop doesn't look at the return value of perf stat, simply
continues.
What I want, and fixed back then, is that if you press ^C foo
terminates, perf stat/record/etc. will finish, but then terminate with
the same signal. In that case bash finally sees the SIGINT and will in
fact terminate the loop.
try:
$ while :; do ./foo /bin/sleep 5 ; done
and try and break out using ^C
---
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(int argc, char *argv[], char *envp[])
{
pid_t pid = fork();
if (!pid) /* child */ {
execve(argv[1], argv+1, envp);
perror("execve");
return;
}
signal(SIGINT, SIG_IGN);
waitpid(pid, NULL, 0);
return 0;
}
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2014-05-07 15:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-24 13:27 [PATCH v3 1/3] perf tools: Handle EINTR error for readn/writen Namhyung Kim
2014-04-24 13:27 ` [PATCH v3 2/3] perf record: Propagate exit status of a command line workload Namhyung Kim
2014-04-25 13:17 ` Stephane Eranian
2014-04-29 10:56 ` Jiri Olsa
2014-04-29 11:19 ` Peter Zijlstra
2014-04-29 11:33 ` Peter Zijlstra
2014-04-29 11:38 ` Jiri Olsa
2014-04-29 11:37 ` Jiri Olsa
2014-04-30 0:24 ` Namhyung Kim
2014-05-07 14:00 ` Jiri Olsa
2014-05-07 15:04 ` Peter Zijlstra [this message]
2014-05-07 17:19 ` Stephane Eranian
2014-05-07 17:35 ` Peter Zijlstra
2014-05-08 7:49 ` Namhyung Kim
2014-04-29 11:15 ` Jiri Olsa
2014-04-29 12:11 ` Peter Zijlstra
2014-04-24 13:27 ` [PATCH v3 3/3] perf tools: Get rid of on_exit() feature test Namhyung Kim
2014-04-25 13:18 ` Stephane Eranian
2014-05-01 6:30 ` [tip:perf/core] perf tools: Handle EINTR error for readn/writen tip-bot for Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140507150404.GO30445@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome