[PATCH v3 1/2] rtla: handle SIGTERM during a run

From: Chaosheng Qu

Date: Sat Nov 21 2026 - 06:32:37 EST


rtla installs a handler for SIGINT, and for SIGALRM when a duration is
given, but not for SIGTERM. A run stopped by the system - a shutdown or
a service manager - therefore dies without going through the cleanup
path and leaves its tracefs instance behind, so the next invocation
finds the instance name in use.

Install the same handler for SIGTERM, and restore the default
disposition in unset_signals().

Fixes: 2f3172f9dd58 ("tools/rtla: Consolidate code between osnoise/timerlat and hist/top")
Signed-off-by: Chaosheng Qu <chaosheng.qu.linux@xxxxxxxxx>
---
tools/tracing/rtla/src/common.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index 8c7f5e75b..b86a60076 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -39,6 +39,7 @@ static void stop_trace(int sig)
static void set_signals(struct common_params *params)
{
signal(SIGINT, stop_trace);
+ signal(SIGTERM, stop_trace);
if (params->duration) {
signal(SIGALRM, stop_trace);
alarm(params->duration);
@@ -51,6 +52,7 @@ static void set_signals(struct common_params *params)
static void unset_signals(struct common_params *params)
{
signal(SIGINT, SIG_DFL);
+ signal(SIGTERM, SIG_DFL);
if (params->duration) {
alarm(0);
signal(SIGALRM, SIG_DFL);
--
2.43.0