From: Intel Date: Mon, 3 Jun 2013 00:00:00 +0000 (+0000) Subject: examples/l3fwd-vf: release resources on SIGINT X-Git-Tag: spdx-start~11186 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=0e8d0d8f05de9a5c7cfab626cf82e9aae0db4fd5;p=dpdk.git examples/l3fwd-vf: release resources on SIGINT Signed-off-by: Intel --- diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c index 79c30a83bf..1ba6cc8b0c 100644 --- a/examples/l3fwd-vf/main.c +++ b/examples/l3fwd-vf/main.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -678,6 +679,24 @@ print_usage(const char *prgname) prgname); } +/* Custom handling of signals to handle process terminal */ +static void +signal_handler(int signum) +{ + uint8_t portid; + uint8_t nb_ports = rte_eth_dev_count(); + + /* When we receive a SIGINT signal */ + if (signum == SIGINT) { + for (portid = 0; portid < nb_ports; portid++) { + /* skip ports that are not enabled */ + if ((enabled_port_mask & (1 << portid)) == 0) + continue; + rte_eth_dev_close(portid); + } + } + rte_exit(EXIT_SUCCESS, "\n User forced exit\n"); +} static int parse_portmask(const char *portmask) { @@ -944,6 +963,7 @@ MAIN(int argc, char **argv) unsigned lcore_id; uint8_t portid, nb_rx_queue, queue, socketid; + signal(SIGINT, signal_handler); /* init EAL */ ret = rte_eal_init(argc, argv); if (ret < 0)