summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRaslan Darawsheh <rasland@mellanox.com>2018-09-27 14:51:44 +0300
committerThomas Monjalon <thomas@monjalon.net>2018-11-04 21:54:04 +0100
commita894d96ee20293af353fc54dc2e801dcaa01e46c (patch)
treef206946319522712729096caac39b463e1a77def /examples
parentb467d38284b1983c172325f2bfacf255b2a90daa (diff)
downloaddpdk-a894d96ee20293af353fc54dc2e801dcaa01e46c.zip
dpdk-a894d96ee20293af353fc54dc2e801dcaa01e46c.tar.gz
dpdk-a894d96ee20293af353fc54dc2e801dcaa01e46c.tar.xz
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>
Diffstat (limited to 'examples')
-rw-r--r--examples/multi_process/client_server_mp/mp_server/main.c15
1 files changed, 15 insertions, 0 deletions
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..0ddc63e 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 <sys/queue.h>
#include <errno.h>
#include <netinet/ip.h>
+#include <signal.h>
#include <rte_common.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
main(int argc, char *argv[])
{
+ signal(SIGINT, signal_handler);
/* initialise the system */
if (init(argc, argv) < 0 )
return -1;