app: do not call printf in signal handlers

Message ID 20230613001150.65407-1-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series app: do not call printf in signal handlers |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-unit-testing success Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Stephen Hemminger June 13, 2023, 12:11 a.m. UTC
  Using printf is not async-signal safe and worst case may lead to deadlock.
Remove printf from signal handlers present in several applications.

Testpmd was already fixed by
commit 0fd1386c30c3 ("app/testpmd: cleanup cleanly from signal")

Signed-off-by: Prateek Agarwal <prateekag@cse.iitb.ac.in>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/pdump/main.c             | 2 --
 app/test-eventdev/evt_main.c | 3 ---
 app/test-flow-perf/main.c    | 3 ---
 app/test/test_pmd_perf.c     | 1 -
 4 files changed, 9 deletions(-)
  

Comments

Tyler Retzlaff June 15, 2023, 8:14 p.m. UTC | #1
On Mon, Jun 12, 2023 at 05:11:50PM -0700, Stephen Hemminger wrote:
> Using printf is not async-signal safe and worst case may lead to deadlock.
> Remove printf from signal handlers present in several applications.
> 
> Testpmd was already fixed by
> commit 0fd1386c30c3 ("app/testpmd: cleanup cleanly from signal")
> 
> Signed-off-by: Prateek Agarwal <prateekag@cse.iitb.ac.in>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
  
Thomas Monjalon June 28, 2023, 12:44 a.m. UTC | #2
15/06/2023 22:14, Tyler Retzlaff:
> On Mon, Jun 12, 2023 at 05:11:50PM -0700, Stephen Hemminger wrote:
> > Using printf is not async-signal safe and worst case may lead to deadlock.
> > Remove printf from signal handlers present in several applications.
> > 
> > Testpmd was already fixed by
> > commit 0fd1386c30c3 ("app/testpmd: cleanup cleanly from signal")
> > 
> > Signed-off-by: Prateek Agarwal <prateekag@cse.iitb.ac.in>
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> 
> Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

Applied, thanks for reviving this old patch.
  

Patch

diff --git a/app/pdump/main.c b/app/pdump/main.c
index c6cf9d9c8769..c94606275b28 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -571,8 +571,6 @@  static void
 signal_handler(int sig_num)
 {
 	if (sig_num == SIGINT) {
-		printf("\n\nSignal %d received, preparing to exit...\n",
-				sig_num);
 		quit_signal = 1;
 	}
 }
diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
index 5c7ac2cce9ab..13a8500ef730 100644
--- a/app/test-eventdev/evt_main.c
+++ b/app/test-eventdev/evt_main.c
@@ -21,9 +21,6 @@  static void
 signal_handler(int signum)
 {
 	if (signum == SIGINT || signum == SIGTERM) {
-		printf("\nSignal %d received, preparing to exit...\n",
-				signum);
-
 		if (test != NULL) {
 			/* request all lcores to exit from the main loop */
 			*(int *)test->test_priv = true;
diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index e0ef78a84013..e224ef67983d 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -1708,9 +1708,6 @@  static void
 signal_handler(int signum)
 {
 	if (signum == SIGINT || signum == SIGTERM) {
-		printf("\n\nSignal %d received, preparing to exit...\n",
-					signum);
-		printf("Error: Stats are wrong due to sudden signal!\n\n");
 		force_quit = true;
 	}
 }
diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index ff84d251ff5f..3ef590cb517d 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -318,7 +318,6 @@  signal_handler(int signum)
 {
 	/*  USR1 signal, stop testing */
 	if (signum == SIGUSR1) {
-		printf("Force Stop!\n");
 		stop = 1;
 	}