From: Zhihong Wang <zhihong.wang@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/3] app/test-pmd: Handle SIGINT and SIGTERM in testpmd
Date: Wed, 23 Dec 2015 15:03:13 -0500 [thread overview]
Message-ID: <1450900995-84185-2-git-send-email-zhihong.wang@intel.com> (raw)
In-Reply-To: <1450900995-84185-1-git-send-email-zhihong.wang@intel.com>
Handle SIGINT and SIGTERM in testpmd.
Signed-off-by: Zhihong Wang <zhihong.wang@intel.com>
---
app/test-pmd/testpmd.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 98ae46d..c259ba3 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1573,6 +1573,7 @@ pmd_test_exit(void)
FOREACH_PORT(pt_id, ports) {
printf("Stopping port %d...", pt_id);
fflush(stdout);
+ rte_eth_dev_stop(pt_id);
rte_eth_dev_close(pt_id);
printf("done\n");
}
@@ -1984,12 +1985,34 @@ init_port(void)
ports[pid].enabled = 1;
}
+/* When we receive a INT signal, close all ports */
+static void
+sigint_handler(__rte_unused int signum)
+{
+ unsigned portid;
+
+ printf("Preparing to exit...\n");
+ FOREACH_PORT(portid, ports) {
+ if (port_id_is_invalid(portid, ENABLED_WARN))
+ continue;
+ printf("Stopping port %d...", portid);
+ rte_eth_dev_stop(portid);
+ rte_eth_dev_close(portid);
+ printf(" Done\n");
+ }
+ printf("Bye...\n");
+ exit(0);
+}
+
int
main(int argc, char** argv)
{
int diag;
uint8_t port_id;
+ signal(SIGINT, sigint_handler);
+ signal(SIGTERM, sigint_handler);
+
diag = rte_eal_init(argc, argv);
if (diag < 0)
rte_panic("Cannot init EAL\n");
--
2.5.0
next prev parent reply other threads:[~2015-12-24 3:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-23 20:03 [dpdk-dev] [PATCH 0/3] Handle SIGINT and SIGTERM in DPDK examples Zhihong Wang
2015-12-23 20:03 ` Zhihong Wang [this message]
2015-12-24 8:09 ` [dpdk-dev] [PATCH 1/3] app/test-pmd: Handle SIGINT and SIGTERM in testpmd Qiu, Michael
2015-12-24 10:18 ` Wang, Zhihong
2015-12-23 20:03 ` [dpdk-dev] [PATCH 2/3] examples/l2fwd: Handle SIGINT and SIGTERM in l2fwd Zhihong Wang
2015-12-24 8:12 ` Qiu, Michael
2015-12-23 20:03 ` [dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in l3fwd Zhihong Wang
2015-12-24 11:13 ` Ananyev, Konstantin
2015-12-25 9:17 ` Wang, Zhihong
[not found] ` <20151224095134.6eea3d4b@xeon-e3>
2015-12-25 9:23 ` Wang, Zhihong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1450900995-84185-2-git-send-email-zhihong.wang@intel.com \
--to=zhihong.wang@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).