add sigint handler in the server application to stop and close ports

Signed-off-by: Raslan Darawsheh <rasl...@mellanox.com>

---
v2:
        - fix includes order
---
---
 examples/multi_process/client_server_mp/mp_server/main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/examples/multi_process/client_server_mp/mp_server/main.c 
b/examples/multi_process/client_server_mp/mp_server/main.c
index 93a9a08..16aa944 100644
--- a/examples/multi_process/client_server_mp/mp_server/main.c
+++ b/examples/multi_process/client_server_mp/mp_server/main.c
@@ -37,6 +37,7 @@
 #include "common.h"
 #include "args.h"
 #include "init.h"
+#include<signal.h>
 
 /*
  * When doing reads from the NIC or the client queues,
@@ -264,9 +265,21 @@ do_packet_forwarding(void)
        }
 }
 
+static void signal_handler(int signal)
+{
+       uint16_t port_id;
+
+       if (signal == SIGINT)
+               RTE_ETH_FOREACH_DEV(port_id) {
+                       rte_eth_dev_stop(port_id);
+                       rte_eth_dev_close(port_id);
+               }
+       exit(0);
+}
 int
 main(int argc, char *argv[])
 {
+       signal(SIGINT, signal_handler);
        /* initialise the system */
        if (init(argc, argv) < 0 )
                return -1;
-- 
2.7.4

Reply via email to