Skip to contentSkip to conversation

examples/kni: fix SIGTERM signal handling

PATCH Superseded [email protected] 3 participants 4 messages Feb 4, 2020 – Feb 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/kni: fix SIGTERM signal handling

From: Vamsi Attunuru <[email protected]>

Current KNI example application is not handling SIGTERM signal when application is killed without passing any specific signal in kill command.

Patch uses the existing signal handler for SIGTERM as well for graceful application exit.

Fixes 13c4ebd65a77 ("examples: minor changes")
---
 examples/kni/main.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
examples/kni/main.c +8 -3
index 5f713e6..29fc37e 100644
@@ -176,9 +176,13 @@ signal_handler(int signum)
 		return;
 	}
 
-	/* When we receive a RTMIN or SIGINT signal, stop kni processing */
-	if (signum == SIGRTMIN || signum == SIGINT){
-		printf("\nSIGRTMIN/SIGINT received. KNI processing stopping.\n");
+	/*
+	 * When we receive a RTMIN or SIGINT or SIGTERM signal,
+	 * stop kni processing
+	 */
+	if (signum == SIGRTMIN || signum == SIGINT || signum == SIGTERM) {
+		printf("\nSIGRTMIN/SIGINT/SIGTERM received. "
+			"KNI processing stopping.\n");
 		rte_atomic32_inc(&kni_stop);
 		return;
         }
@@ -1006,6 +1010,7 @@ main(int argc, char** argv)
 	signal(SIGUSR2, signal_handler);
 	signal(SIGRTMIN, signal_handler);
 	signal(SIGINT, signal_handler);
+	signal(SIGTERM, signal_handler);
 
 	/* Initialise EAL */
 	ret = rte_eal_init(argc, argv);
Signature · 1 line
2.8.4
#1 lore raw
Quoted 11 lines · On 2/4/2020 8:42 AM, [email protected] wrote:

From: Vamsi Attunuru <[email protected]>

Current KNI example application is not handling SIGTERM signal when application is killed without passing any specific signal in kill command.

Patch uses the existing signal handler for SIGTERM as well for graceful application exit.

Fixes 13c4ebd65a77 ("examples: minor changes")

Hi Vamsi,

No concern adding SIGTERM handling, although you can use 'kill' to send supported signal (or just C-c (SIGINT)), it doesn't hurt to handle SIGTERM too but that is not a fix.

Can you please reword to commit log to say SIGTERM handling added? Feel free to add my ack on to it.

Quoted 36 lines
---
 examples/kni/main.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
examples/kni/main.c +8 -3
index 5f713e6..29fc37e 100644
@@ -176,9 +176,13 @@ signal_handler(int signum)
 		return;
 	}
 
-	/* When we receive a RTMIN or SIGINT signal, stop kni processing */
-	if (signum == SIGRTMIN || signum == SIGINT){
-		printf("\nSIGRTMIN/SIGINT received. KNI processing stopping.\n");
+	/*
+	 * When we receive a RTMIN or SIGINT or SIGTERM signal,
+	 * stop kni processing
+	 */
+	if (signum == SIGRTMIN || signum == SIGINT || signum == SIGTERM) {
+		printf("\nSIGRTMIN/SIGINT/SIGTERM received. "
+			"KNI processing stopping.\n");
 		rte_atomic32_inc(&kni_stop);
 		return;
         }
@@ -1006,6 +1010,7 @@ main(int argc, char** argv)
 	signal(SIGUSR2, signal_handler);
 	signal(SIGRTMIN, signal_handler);
 	signal(SIGINT, signal_handler);
+	signal(SIGTERM, signal_handler);
 
 	/* Initialise EAL */
 	ret = rte_eal_init(argc, argv);
#2 lore raw

PATCH v2 1/1 examples/kni: add SIGTERM signal handling

In reply to [email protected]

From: Vamsi Attunuru <[email protected]>

SIGTERM handling is added for graceful application exit. Useful when application is terminated without specifying any signal on 'kill' command.

---
v2 Change:
* Changed commit log

 examples/kni/main.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
examples/kni/main.c +8 -3
index 5f713e6..29fc37e 100644
@@ -176,9 +176,13 @@ signal_handler(int signum)
 		return;
 	}
 
-	/* When we receive a RTMIN or SIGINT signal, stop kni processing */
-	if (signum == SIGRTMIN || signum == SIGINT){
-		printf("\nSIGRTMIN/SIGINT received. KNI processing stopping.\n");
+	/*
+	 * When we receive a RTMIN or SIGINT or SIGTERM signal,
+	 * stop kni processing
+	 */
+	if (signum == SIGRTMIN || signum == SIGINT || signum == SIGTERM) {
+		printf("\nSIGRTMIN/SIGINT/SIGTERM received. "
+			"KNI processing stopping.\n");
 		rte_atomic32_inc(&kni_stop);
 		return;
         }
@@ -1006,6 +1010,7 @@ main(int argc, char** argv)
 	signal(SIGUSR2, signal_handler);
 	signal(SIGRTMIN, signal_handler);
 	signal(SIGINT, signal_handler);
+	signal(SIGTERM, signal_handler);
 
 	/* Initialise EAL */
 	ret = rte_eal_init(argc, argv);
Signature · 1 line
2.8.4
#3 lore raw

Re: [dpdk-dev] [PATCH] [v2 1/1] examples/kni: add SIGTERM signal handling

Quoted 9 lines · On Thu, Feb 6, 2020 at 12:54 PM <[email protected]> wrote:

From: Vamsi Attunuru <[email protected]>

SIGTERM handling is added for graceful application exit. Useful when application is terminated without specifying any signal on 'kill' command.

Applied, thanks.

--
David Marchand