[v2,1/1] examples/kni: add SIGTERM signal handling

Message ID 20200206115357.19827-1-vattunuru@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [v2,1/1] examples/kni: add SIGTERM signal handling |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation fail apply issues

Commit Message

Vamsi Krishna Attunuru Feb. 6, 2020, 11:53 a.m. UTC
  From: Vamsi Attunuru <vattunuru@marvell.com>

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

Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
v2 Change:
* Changed commit log

 examples/kni/main.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
  

Comments

David Marchand Feb. 13, 2020, 5:36 p.m. UTC | #1
On Thu, Feb 6, 2020 at 12:54 PM <vattunuru@marvell.com> wrote:
>
> From: Vamsi Attunuru <vattunuru@marvell.com>
>
> SIGTERM handling is added for graceful application exit.
> Useful when application is terminated without specifying
> any signal on 'kill' command.
>
> Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks.


--
David Marchand
  

Patch

diff --git a/examples/kni/main.c b/examples/kni/main.c
index 5f713e6..29fc37e 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -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);