mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.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: Tue, 29 Apr 2014 13:15:51 +0200	[thread overview]
Message-ID: <20140429111551.GC1148@krava.brq.redhat.com> (raw)
In-Reply-To: <1398346054-3322-2-git-send-email-namhyung@kernel.org>

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);
 

  parent reply	other threads:[~2014-04-29 11:16 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
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 [this message]
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=20140429111551.GC1148@krava.brq.redhat.com \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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

all inboxes | Powered by JetHome®