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 <rasland@mellanox.com>
This commit is contained in:
Raslan Darawsheh 2018-09-27 14:51:44 +03:00 committed by Thomas Monjalon
parent b467d38284
commit a894d96ee2

View File

@ -12,6 +12,7 @@
#include <sys/queue.h> #include <sys/queue.h>
#include <errno.h> #include <errno.h>
#include <netinet/ip.h> #include <netinet/ip.h>
#include <signal.h>
#include <rte_common.h> #include <rte_common.h>
#include <rte_memory.h> #include <rte_memory.h>
@ -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 int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
signal(SIGINT, signal_handler);
/* initialise the system */ /* initialise the system */
if (init(argc, argv) < 0 ) if (init(argc, argv) < 0 )
return -1; return -1;