Skip to contentSkip to conversation

Remove printf from signal handler.

PATCH In review Prateek Agarwal 7 participants 9 messages Dec 4, 2020 – Jun 28, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove printf from signal handler.

printf is not async-signal safe. Using printf in signal handlers may lead to deadlock. Removed printf from signal handlers present in several applications.

---
 app/pdump/main.c             | 2 --
 app/test-eventdev/evt_main.c | 4 ----
 app/test-flow-perf/main.c    | 3 ---
 app/test-pmd/testpmd.c       | 2 --
 app/test/test_pmd_perf.c     | 1 -
 5 files changed, 12 deletions(-)
app/pdump/main.c +0 -2
index b34bf3353..380f0ea0f 100644
@@ -573,8 +573,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;
 	}
 }
app/test-eventdev/evt_main.c +0 -4
index a8d304bab..51d5897f8 100644
@@ -22,12 +22,8 @@ signal_handler(int signum)
 {
 	int i;
 	static uint8_t once;
-
 	if ((signum == SIGINT || signum == SIGTERM) && !once) {
 		once = true;
-		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;
app/test-flow-perf/main.c +0 -3
index 03d01a8b5..aeb0ef3b0 100644
@@ -1001,9 +1001,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;
 	}
 }
app/test-pmd/testpmd.c +0 -2
index 33fc0fddf..7ec87e7fd 100644
@@ -3794,8 +3794,6 @@ static void
 signal_handler(int signum)
 {
 	if (signum == SIGINT || signum == SIGTERM) {
-		printf("\nSignal %d received, preparing to exit...\n",
-				signum);
 #ifdef RTE_LIB_PDUMP
 		/* uninitialize packet capture framework */
 		rte_pdump_uninit();
app/test/test_pmd_perf.c +0 -1
index 4db816a36..58cb84401 100644
@@ -319,7 +319,6 @@ signal_handler(int signum)
 {
 	/*  USR1 signal, stop testing */
 	if (signum == SIGUSR1) {
-		printf("Force Stop!\n");
 		stop = 1;
 	}
 
Signature · 1 line
2.25.1
#1 lore raw

Hi
I don't object with all the removing of printf.
Just one concern, I don't think you actually solved the problem in this patch.

Take testpmd as an example, the signal_handler includes many complicated actions after that very first printf like force_quit() which includes stop port, close port, hotplug... and of course a lot of printf in it. So only removing the first printf doesn't actually solve the issue you mentioned.

And many examples do similar things as testpmd, they have the same issues too.

BRs
Xiaoyun

Quoted 89 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Prateek Agarwal
Sent: Saturday, December 5, 2020 01:52
To: [email protected]
Cc: [email protected]; Prateek Agarwal <[email protected]>; Prateek Agarwal <[email protected]>
Subject: [dpdk-dev] [PATCH] Remove printf from signal handler.

printf is not async-signal safe. Using printf in signal handlers may lead to deadlock. Removed printf from signal handlers present in several applications.

---
 app/pdump/main.c             | 2 --
 app/test-eventdev/evt_main.c | 4 ----
 app/test-flow-perf/main.c    | 3 ---
 app/test-pmd/testpmd.c       | 2 --
 app/test/test_pmd_perf.c     | 1 -
 5 files changed, 12 deletions(-)
app/pdump/main.c index renamed from app/pdump/main.c +0 -0

b34bf3353..380f0ea0f 100644

app/pdump/main.c +0 -2
@@ -573,8 +573,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;
 	}
 }
app/test-eventdev/evt_main.c +0 -4
index a8d304bab..51d5897f8 100644
@@ -22,12 +22,8 @@ signal_handler(int signum)  {
 	int i;
 	static uint8_t once;
-
 	if ((signum == SIGINT || signum == SIGTERM) && !once) {
 		once = true;
-		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;
app/test-flow-perf/main.c index renamed from app/test-flow-perf/main.c +0 -0

03d01a8b5..aeb0ef3b0 100644

app/test-flow-perf/main.c +0 -3
@@ -1001,9 +1001,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;
 	}
 }
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

33fc0fddf..7ec87e7fd 100644

app/test-pmd/testpmd.c +0 -2
@@ -3794,8 +3794,6 @@ static void
 signal_handler(int signum)
 {
 	if (signum == SIGINT || signum == SIGTERM) {
-		printf("\nSignal %d received, preparing to exit...\n",
-				signum);
 #ifdef RTE_LIB_PDUMP
 		/* uninitialize packet capture framework */
 		rte_pdump_uninit();
app/test/test_pmd_perf.c index renamed from app/test/test_pmd_perf.c +0 -0

4db816a36..58cb84401 100644

app/test/test_pmd_perf.c +0 -2
@@ -319,7 +319,6 @@ signal_handler(int signum)  {
 	/*  USR1 signal, stop testing */
 	if (signum == SIGUSR1) {
-		printf("Force Stop!\n");
 		stop = 1;
 	}
 
--

2.25.1

#2 lore raw

Hi
Agree. What is the way out? The printfs you mentioned look like important messages and may have been called outside signal handler routines. Shall they be removed as well or converted to "write" function call? Or we live with the possiblity of deadlock howsoever unlikely. Regards
Prateek Agarwal

Quoted 103 lines · Xiaoyun

Hi
I don't object with all the removing of printf.
Just one concern, I don't think you actually solved the problem in this patch.

Take testpmd as an example, the signal_handler includes many complicated actions after that very first printf like force_quit() which includes stop port, close port, hotplug... and of course a lot of printf in it.
So only removing the first printf doesn't actually solve the issue you mentioned.

And many examples do similar things as testpmd, they have the same issues too.

BRs
Xiaoyun

Quoted 89 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Prateek Agarwal
Sent: Saturday, December 5, 2020 01:52
To: [email protected]
Cc: [email protected]; Prateek Agarwal <[email protected]>; Prateek Agarwal <[email protected]>
Subject: [dpdk-dev] [PATCH] Remove printf from signal handler.

printf is not async-signal safe. Using printf in signal handlers may lead to deadlock. Removed printf from signal handlers present in several applications.

---
 app/pdump/main.c             | 2 --
 app/test-eventdev/evt_main.c | 4 ----
 app/test-flow-perf/main.c    | 3 ---
 app/test-pmd/testpmd.c       | 2 --
 app/test/test_pmd_perf.c     | 1 -
 5 files changed, 12 deletions(-)
app/pdump/main.c index renamed from app/pdump/main.c +0 -0

b34bf3353..380f0ea0f 100644

app/pdump/main.c +0 -2
@@ -573,8 +573,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;
 	}
 }
app/test-eventdev/evt_main.c +0 -4
index a8d304bab..51d5897f8 100644
@@ -22,12 +22,8 @@ signal_handler(int signum)  {
 	int i;
 	static uint8_t once;
-
 	if ((signum == SIGINT || signum == SIGTERM) && !once) {
 		once = true;
-		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;
app/test-flow-perf/main.c index renamed from app/test-flow-perf/main.c +0 -0

03d01a8b5..aeb0ef3b0 100644

app/test-flow-perf/main.c +0 -3
@@ -1001,9 +1001,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;
 	}
 }
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

33fc0fddf..7ec87e7fd 100644

app/test-pmd/testpmd.c +0 -2
@@ -3794,8 +3794,6 @@ static void
 signal_handler(int signum)
 {
 	if (signum == SIGINT || signum == SIGTERM) {
-		printf("\nSignal %d received, preparing to exit...\n",
-				signum);
 #ifdef RTE_LIB_PDUMP
 		/* uninitialize packet capture framework */
 		rte_pdump_uninit();
app/test/test_pmd_perf.c index renamed from app/test/test_pmd_perf.c +0 -0

4db816a36..58cb84401 100644

app/test/test_pmd_perf.c +0 -2
@@ -319,7 +319,6 @@ signal_handler(int signum)  {
 	/*  USR1 signal, stop testing */
 	if (signum == SIGUSR1) {
-		printf("Force Stop!\n");
 		stop = 1;
 	}
 
--

2.25.1

#3 lore raw

Hi
I don't have a good solution here.
Removing doesn't seem a good idea because there are many important alerts or reminders in all of those function calls and they may be called in other places too. I think replacing with "write" can't solve the problem too. Because behavior like stopping port will call driver functions. It's not very reasonable to me that replacing all possible logs. Use a flag and check the flag for each possible thread? Most examples already do this way. But for complicated app, it will be tricky and may cause other issues.

Maybe other people have better ideas?

BRs
Xiaoyun

Quoted 127 lines

-----Original Message-----
From: prateekag <[email protected]>
Sent: Thursday, December 10, 2020 08:28
To: Li, Xiaoyun <[email protected]>
Cc: Prateek Agarwal <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH] Remove printf from signal handler.

Hi
Agree. What is the way out? The printfs you mentioned look like important messages and may have been called outside signal handler routines. Shall they be removed as well or converted to "write" function call? Or we live with the possiblity of deadlock howsoever unlikely.
Regards
Prateek Agarwal

Quoted 109 lines · Xiaoyun

Hi
I don't object with all the removing of printf.
Just one concern, I don't think you actually solved the problem in this patch.

Take testpmd as an example, the signal_handler includes many complicated actions after that very first printf like force_quit() which includes stop port, close port, hotplug... and of course a lot of printf in it. So only removing the first printf doesn't actually solve the issue you mentioned.

And many examples do similar things as testpmd, they have the same issues too.

BRs
Xiaoyun

Quoted 92 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Prateek Agarwal
Sent: Saturday, December 5, 2020 01:52
To: [email protected]
Cc: [email protected]; Prateek Agarwal <[email protected]>; Prateek Agarwal <[email protected]>
Subject: [dpdk-dev] [PATCH] Remove printf from signal handler.

printf is not async-signal safe. Using printf in signal handlers may lead to deadlock. Removed printf from signal handlers present in several applications.

---
 app/pdump/main.c             | 2 --
 app/test-eventdev/evt_main.c | 4 ----
 app/test-flow-perf/main.c    | 3 ---
 app/test-pmd/testpmd.c       | 2 --
 app/test/test_pmd_perf.c     | 1 -
 5 files changed, 12 deletions(-)
app/pdump/main.c index renamed from app/pdump/main.c +0 -0

b34bf3353..380f0ea0f 100644

app/pdump/main.c +0 -2
@@ -573,8 +573,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;
 	}
 }
(quoted diff) +0 -0

b/app/test-eventdev/evt_main.c index a8d304bab..51d5897f8 100644

app/test-eventdev/evt_main.c +0 -4
@@ -22,12 +22,8 @@ signal_handler(int signum)  {
 	int i;
 	static uint8_t once;
-
 	if ((signum == SIGINT || signum == SIGTERM) && !once) {
 		once = true;
-		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;
app/test-flow-perf/main.c +0 -0

index
03d01a8b5..aeb0ef3b0 100644

app/test-flow-perf/main.c +0 -3
@@ -1001,9 +1001,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;
 	}
 }
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

33fc0fddf..7ec87e7fd 100644

app/test-pmd/testpmd.c +0 -2
@@ -3794,8 +3794,6 @@ static void
 signal_handler(int signum)
 {
 	if (signum == SIGINT || signum == SIGTERM) {
-		printf("\nSignal %d received, preparing to exit...\n",
-				signum);
 #ifdef RTE_LIB_PDUMP
 		/* uninitialize packet capture framework */
 		rte_pdump_uninit();
app/test/test_pmd_perf.c +0 -0

index
4db816a36..58cb84401 100644

app/test/test_pmd_perf.c +0 -2
@@ -319,7 +319,6 @@ signal_handler(int signum)  {
 	/*  USR1 signal, stop testing */
 	if (signum == SIGUSR1) {
-		printf("Force Stop!\n");
 		stop = 1;
 	}
 
--

2.25.1

#4 lore raw
Quoted 9 lines

Hi
I don't have a good solution here.
Removing doesn't seem a good idea because there are many important alerts or reminders in all of those function calls and they may be called in other places too.
I think replacing with "write" can't solve the problem too. Because behavior like stopping port will call driver functions. It's not very reasonable to me that replacing all possible logs.
Use a flag and check the flag for each possible thread? Most examples already do this way. But for complicated app, it will be tricky and may cause other issues.

I wonder do we really have to try to 'fix' that?
I don't remember anyone complained about such problem in 10 years DPDK exists. Konstantin

Quoted 133 lines

Maybe other people have better ideas?

BRs
Xiaoyun

Quoted 127 lines

-----Original Message-----
From: prateekag <[email protected]>
Sent: Thursday, December 10, 2020 08:28
To: Li, Xiaoyun <[email protected]>
Cc: Prateek Agarwal <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH] Remove printf from signal handler.

Hi
Agree. What is the way out? The printfs you mentioned look like important messages and may have been called outside signal handler routines. Shall they be removed as well or converted to "write" function call? Or we live with the possiblity of deadlock howsoever unlikely.
Regards
Prateek Agarwal

Quoted 109 lines · Xiaoyun

Hi
I don't object with all the removing of printf.
Just one concern, I don't think you actually solved the problem in this patch.

Take testpmd as an example, the signal_handler includes many complicated actions after that very first printf like force_quit() which includes stop port, close port, hotplug... and of course a lot of printf in it. So only removing the first printf doesn't actually solve the issue you mentioned.

And many examples do similar things as testpmd, they have the same issues too.

BRs
Xiaoyun

Quoted 92 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Prateek Agarwal
Sent: Saturday, December 5, 2020 01:52
To: [email protected]
Cc: [email protected]; Prateek Agarwal <[email protected]>; Prateek Agarwal <[email protected]>
Subject: [dpdk-dev] [PATCH] Remove printf from signal handler.

printf is not async-signal safe. Using printf in signal handlers may lead to deadlock. Removed printf from signal handlers present in several applications.

---
 app/pdump/main.c             | 2 --
 app/test-eventdev/evt_main.c | 4 ----
 app/test-flow-perf/main.c    | 3 ---
 app/test-pmd/testpmd.c       | 2 --
 app/test/test_pmd_perf.c     | 1 -
 5 files changed, 12 deletions(-)
app/pdump/main.c index renamed from app/pdump/main.c +0 -0

b34bf3353..380f0ea0f 100644

app/pdump/main.c +0 -2
@@ -573,8 +573,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;
 	}
 }
(quoted diff) +0 -0

b/app/test-eventdev/evt_main.c index a8d304bab..51d5897f8 100644

app/test-eventdev/evt_main.c +0 -4
@@ -22,12 +22,8 @@ signal_handler(int signum)  {
 	int i;
 	static uint8_t once;
-
 	if ((signum == SIGINT || signum == SIGTERM) && !once) {
 		once = true;
-		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;
app/test-flow-perf/main.c +0 -0

index
03d01a8b5..aeb0ef3b0 100644

app/test-flow-perf/main.c +0 -3
@@ -1001,9 +1001,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;
 	}
 }
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

33fc0fddf..7ec87e7fd 100644

app/test-pmd/testpmd.c +0 -2
@@ -3794,8 +3794,6 @@ static void
 signal_handler(int signum)
 {
 	if (signum == SIGINT || signum == SIGTERM) {
-		printf("\nSignal %d received, preparing to exit...\n",
-				signum);
 #ifdef RTE_LIB_PDUMP
 		/* uninitialize packet capture framework */
 		rte_pdump_uninit();
app/test/test_pmd_perf.c +0 -0

index
4db816a36..58cb84401 100644

app/test/test_pmd_perf.c +0 -2
@@ -319,7 +319,6 @@ signal_handler(int signum)  {
 	/*  USR1 signal, stop testing */
 	if (signum == SIGUSR1) {
-		printf("Force Stop!\n");
 		stop = 1;
 	}
 
--

2.25.1

#5 lore raw

Hi,

We reused some code snippets of signal handlers in one of our projects and faced this problem of deadlock when the user sent an interrupt signal (ctrl-C) in quick succession.

This is a non-deterministic bug and highly unlikely to be observed frequently. The main idea behind pointing out was to look at the possible solutions suggested by the community. Another reason was to make everyone aware of this bug.

Anyways, leaving a comment in the source or mentioning this in documentation may not be a bad idea.

Regards
Prateek Agarwal

Quoted 146 lines · Konstantin
Quoted 8 lines

Hi
I don't have a good solution here.
Removing doesn't seem a good idea because there are many important alerts or reminders in all of those function calls and they may be called in other places too.
I think replacing with "write" can't solve the problem too. Because behavior like stopping port will call driver functions. It's not very reasonable to me that replacing all possible logs.
Use a flag and check the flag for each possible thread? Most examples already do this way. But for complicated app, it will be tricky and may cause other issues.

I wonder do we really have to try to 'fix' that?
I don't remember anyone complained about such problem in 10 years DPDK exists. Konstantin

Quoted 133 lines

Maybe other people have better ideas?

BRs
Xiaoyun

Quoted 127 lines

-----Original Message-----
From: prateekag <[email protected]>
Sent: Thursday, December 10, 2020 08:28
To: Li, Xiaoyun <[email protected]>
Cc: Prateek Agarwal <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH] Remove printf from signal handler.

Hi
Agree. What is the way out? The printfs you mentioned look like important messages and may have been called outside signal handler routines. Shall they be removed as well or converted to "write" function call? Or we live with the possiblity of deadlock howsoever unlikely.
Regards
Prateek Agarwal

Quoted 109 lines · Xiaoyun

Hi
I don't object with all the removing of printf.
Just one concern, I don't think you actually solved the problem in this patch.

Take testpmd as an example, the signal_handler includes many complicated actions after that very first printf like force_quit() which includes stop port, close port, hotplug... and of course a lot of printf in it. So only removing the first printf doesn't actually solve the issue you mentioned.

And many examples do similar things as testpmd, they have the same issues too.

BRs
Xiaoyun

Quoted 92 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Prateek Agarwal
Sent: Saturday, December 5, 2020 01:52
To: [email protected]
Cc: [email protected]; Prateek Agarwal <[email protected]>; Prateek Agarwal <[email protected]>
Subject: [dpdk-dev] [PATCH] Remove printf from signal handler.

printf is not async-signal safe. Using printf in signal handlers may lead to deadlock. Removed printf from signal handlers present in several applications.

---
 app/pdump/main.c             | 2 --
 app/test-eventdev/evt_main.c | 4 ----
 app/test-flow-perf/main.c    | 3 ---
 app/test-pmd/testpmd.c       | 2 --
 app/test/test_pmd_perf.c     | 1 -
 5 files changed, 12 deletions(-)
app/pdump/main.c index renamed from app/pdump/main.c +0 -0

b34bf3353..380f0ea0f 100644

app/pdump/main.c +0 -2
@@ -573,8 +573,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;
 	}
 }
(quoted diff) +0 -0

b/app/test-eventdev/evt_main.c index a8d304bab..51d5897f8 100644

app/test-eventdev/evt_main.c +0 -4
@@ -22,12 +22,8 @@ signal_handler(int signum)  {
 	int i;
 	static uint8_t once;
-
 	if ((signum == SIGINT || signum == SIGTERM) && !once) {
 		once = true;
-		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;
app/test-flow-perf/main.c +0 -0

index
03d01a8b5..aeb0ef3b0 100644

app/test-flow-perf/main.c +0 -3
@@ -1001,9 +1001,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;
 	}
 }
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

33fc0fddf..7ec87e7fd 100644

app/test-pmd/testpmd.c +0 -2
@@ -3794,8 +3794,6 @@ static void
 signal_handler(int signum)
 {
 	if (signum == SIGINT || signum == SIGTERM) {
-		printf("\nSignal %d received, preparing to exit...\n",
-				signum);
 #ifdef RTE_LIB_PDUMP
 		/* uninitialize packet capture framework */
 		rte_pdump_uninit();
app/test/test_pmd_perf.c +0 -0

index
4db816a36..58cb84401 100644

app/test/test_pmd_perf.c +0 -2
@@ -319,7 +319,6 @@ signal_handler(int signum)  {
 	/*  USR1 signal, stop testing */
 	if (signum == SIGUSR1) {
-		printf("Force Stop!\n");
 		stop = 1;
 	}
 
--

2.25.1

#6 lore raw

PATCH 1/1 app: do not call printf in signal handlers

In reply to Prateek Agarwal

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")

---
 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(-)
app/pdump/main.c +0 -2
index c6cf9d9c8769..c94606275b28 100644
@@ -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;
 	}
 }
app/test-eventdev/evt_main.c +0 -3
index 5c7ac2cce9ab..13a8500ef730 100644
@@ -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;
app/test-flow-perf/main.c +0 -3
index e0ef78a84013..e224ef67983d 100644
@@ -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;
 	}
 }
app/test/test_pmd_perf.c +0 -1
index ff84d251ff5f..3ef590cb517d 100644
@@ -318,7 +318,6 @@ signal_handler(int signum)
 {
 	/*  USR1 signal, stop testing */
 	if (signum == SIGUSR1) {
-		printf("Force Stop!\n");
 		stop = 1;
 	}
 
Signature · 1 line
2.39.2
Acked-by on v1 1/1
#7 lore raw

Re: [PATCH] app: do not call printf in signal handlers

Quoted 9 lines · Stephen Hemminger

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")

---

#8 lore raw

Re: [PATCH] app: do not call printf in signal handlers

15/06/2023 22:14, Tyler Retzlaff:

Quoted 12 lines · Stephen Hemminger
Quoted 9 lines

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")

---

Applied, thanks for reviving this old patch.