[PATCH stalld 32/52] tests: Fix async-signal-unsafe handler

Wander Lairson Costa <[email protected]> Mon, 8 Jun 2026 15:31:42 -0300
Newsgroups org.kernel.vger.linux-rt-users
Message-ID <[email protected]>
Remove the printf call from the starvation_gen signal handler.
Calling printf from a signal handler is undefined behavior under
POSIX because it is not async-signal-safe. If the signal arrives
while another thread holds the internal stdout lock, the process
deadlocks. The handler now only sets the volatile running flag.

Signed-off-by: Wander Lairson Costa <[email protected]>
---
 tests/helpers/starvation_gen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/helpers/starvation_gen.c b/tests/helpers/starvation_gen.c
index 81ee714..88cedac 100644
--- a/tests/helpers/starvation_gen.c
+++ b/tests/helpers/starvation_gen.c
@@ -102,7 +102,7 @@ void *blockee_thread(void *arg) {
 }
 
 void signal_handler(int sig) {
-	printf("\nReceived signal %d, exiting...\n", sig);
+	(void)sig;
 	running = 0;
 }
 
-- 
2.54.0