diff options
author | Steven Rostedt (Google) <rostedt@goodmis.org> | 2023-01-06 13:39:30 -0500 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2023-01-09 13:12:37 -0500 |
commit | 184b1d737ca44259ee504db2f29f3cb0d59e4e20 (patch) | |
tree | 6f9d6b91f86b2ed4a0ccd2044ae86cce25d24a5d | |
parent | 53bb1122b719d76cccebff50154ff5490dcf12d8 (diff) | |
download | trace-cmd-184b1d737ca44259ee504db2f29f3cb0d59e4e20.tar.gz |
trace-cmd record: Keep stopping the recording when finished
The tracecmd_stop_recording() is suppose to force the recorders to finish,
but because it is called from a signal handler, that may not necessarily be
the case (due to race conditions and such). Set an alarm to try again in a
second, then after two seconds, and then three, and so on.
Link: https://lore.kernel.org/linux-trace-devel/20230106183930.12565-11-rostedt@goodmis.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r-- | tracecmd/trace-record.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index b3614b07..7f0cebe8 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -3164,11 +3164,21 @@ static void expand_event_list(void) static void finish(void) { + static int secs = 1; + sleep_time = 0; /* all done */ - if (recorder) + if (recorder) { tracecmd_stop_recording(recorder); + /* + * We could just call the alarm if the above returned non zero, + * as zero is suppose to guarantee that the reader woke up. + * But as this is called from a signal handler, that may not + * necessarily be the case. + */ + alarm(secs++); + } finished = 1; } @@ -3181,6 +3191,7 @@ static void flush(void) static void do_sig(int sig) { switch (sig) { + case SIGALRM: case SIGUSR1: case SIGINT: return finish(); @@ -3432,6 +3443,7 @@ static int create_recorder(struct buffer_instance *instance, int cpu, signal(SIGINT, SIG_IGN); signal(SIGUSR1, do_sig); signal(SIGUSR2, do_sig); + signal(SIGALRM, do_sig); if (rt_prio) set_prio(rt_prio); |