From a894d96ee20293af353fc54dc2e801dcaa01e46c Mon Sep 17 00:00:00 2001 From: Raslan Darawsheh Date: Thu, 27 Sep 2018 14:51:44 +0300 Subject: [PATCH] examples/multi_process: add sigint handler to server add sigint handler in the server application to stop and close ports Signed-off-by: Raslan Darawsheh --- .../client_server_mp/mp_server/main.c | 15 +++++++++++++++ 1 file changed, 15 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 93a9a08922..0ddc63e925 100644 --- a/examples/multi_process/client_server_mp/mp_server/main.c +++ b/examples/multi_process/client_server_mp/mp_server/main.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -264,9 +265,23 @@ 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.20.1