Thread (30 messages) flat view 30 messages, 3 authors, 12d ago

Re: [PATCH 09/13] examples/ipsecgw: do not print from signal handler

From: Radu Nicolau <hidden>
Date: 2026-09-08 11:19:22

On 07-Sep-26 12:24 AM, Stephen Hemminger wrote:
quoted hunk ↗ jump to hunk
The SIGINT handler calls printf which is not async-signal safe.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
  examples/ipsec-secgw/ipsec-secgw.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index eba7560c9b..4816bcdd82 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -2448,11 +2448,8 @@ create_default_ipsec_flow(uint16_t port_id, uint64_t rx_offloads)
  static void
  signal_handler(int signum)
  {
-	if (signum == SIGINT || signum == SIGTERM) {
-		printf("\n\nSignal %d received, preparing to exit...\n",
-				signum);
+	if (signum == SIGINT || signum == SIGTERM)
  		force_quit = true;
-	}
  }
  
  static void
I think the same applies to interrupt callbacks (e.g.rte_eth_dev_cb_fn 
), many example apps are using printf in those too.

 From what I see write() is required to be async signal safe and can be 
used instead, in signal handlers and event callbacks, but we will lose 
the va args / format specifiers.

https://man7.org/linux/man-pages/man7/signal-safety.7.html


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help