From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Cc: Avidan Borisov <avidanborisov@gmail.com>,
Ross Zwisler <zwisler@google.com>,
"Steven Rostedt (Google)" <rostedt@goodmis.org>
Subject: [PATCH 1/2] trace-cmd record: Use SIGTERM as well for --daemonize
Date: Tue, 17 Oct 2023 19:20:28 -0400 [thread overview]
Message-ID: <20231017233503.2205514-2-rostedt@goodmis.org> (raw)
In-Reply-To: <20231017233503.2205514-1-rostedt@goodmis.org>
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Currently --daemonize expects a SIGINT to stop the daemon and build the
trace.dat file. But if the user just does a:
kill <pid>
it will send a SIGTERM. This will actually kill the process and it will
not create the trace.dat file, leaving a bunch of trace.dat.cpuX files
just lying around.
Update it to also do the same with SIGTERM.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tracecmd/trace-record.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 69a10bf1f0bd..c943f486291e 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -3344,6 +3344,7 @@ static void do_sig(int sig)
case SIGALRM:
case SIGUSR1:
case SIGINT:
+ case SIGTERM:
return finish();
case SIGUSR2:
return flush();
@@ -3591,6 +3592,7 @@ static int create_recorder(struct buffer_instance *instance, int cpu,
return pid;
signal(SIGINT, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
signal(SIGUSR1, do_sig);
signal(SIGUSR2, do_sig);
signal(SIGALRM, do_sig);
@@ -7146,6 +7148,7 @@ static void record_trace(int argc, char **argv,
if (type & (TRACE_TYPE_RECORD | TRACE_TYPE_STREAM)) {
signal(SIGINT, do_sig);
+ signal(SIGTERM, do_sig);
if (!latency)
start_threads(type, ctx);
}
@@ -7182,7 +7185,7 @@ static void record_trace(int argc, char **argv,
if (do_daemonize) {
daemonize_finish();
- printf("Send SIGINT to pid %d to stop recording\n", getpid());
+ printf("Send SIGINT/SIGTERM to pid %d to stop recording\n", getpid());
} else {
/* sleep till we are woken with Ctrl^C */
printf("Hit Ctrl^C to stop recording\n");
--
2.42.0
next prev parent reply other threads:[~2023-10-17 23:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 23:20 [PATCH 0/2] trace-cmd: Cleanups for --daemonize option Steven Rostedt
2023-10-17 23:20 ` Steven Rostedt [this message]
2023-10-17 23:20 ` [PATCH 2/2] trace-cmd record: Cleanup - be consistent with return status variable Steven Rostedt
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=20231017233503.2205514-2-rostedt@goodmis.org \
--to=rostedt@goodmis.org \
--cc=avidanborisov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=zwisler@google.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).