From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 11CCE5A57 for ; Thu, 24 Dec 2015 09:10:36 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 24 Dec 2015 00:10:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,472,1444719600"; d="scan'208";a="877930113" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga002.jf.intel.com with ESMTP; 24 Dec 2015 00:10:34 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 24 Dec 2015 00:09:55 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 24 Dec 2015 00:09:55 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.190]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.105]) with mapi id 14.03.0248.002; Thu, 24 Dec 2015 16:09:53 +0800 From: "Qiu, Michael" To: "Wang, Zhihong" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 1/3] app/test-pmd: Handle SIGINT and SIGTERM in testpmd Thread-Index: AQHRPfgvB2TtwaxBa0ek9TViU+l3eA== Date: Thu, 24 Dec 2015 08:09:51 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E6028622F001E7@SHSMSX101.ccr.corp.intel.com> References: <1450900995-84185-1-git-send-email-zhihong.wang@intel.com> <1450900995-84185-2-git-send-email-zhihong.wang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 1/3] app/test-pmd: Handle SIGINT and SIGTERM in testpmd X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Dec 2015 08:10:37 -0000 On 12/24/2015 11:07 AM, Zhihong Wang wrote:=0A= > Handle SIGINT and SIGTERM in testpmd.=0A= >=0A= > Signed-off-by: Zhihong Wang =0A= > ---=0A= > app/test-pmd/testpmd.c | 23 +++++++++++++++++++++++=0A= > 1 file changed, 23 insertions(+)=0A= >=0A= > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c=0A= > index 98ae46d..c259ba3 100644=0A= > --- a/app/test-pmd/testpmd.c=0A= > +++ b/app/test-pmd/testpmd.c=0A= > @@ -1573,6 +1573,7 @@ pmd_test_exit(void)=0A= > FOREACH_PORT(pt_id, ports) {=0A= > printf("Stopping port %d...", pt_id);=0A= > fflush(stdout);=0A= > + rte_eth_dev_stop(pt_id);=0A= > rte_eth_dev_close(pt_id);=0A= > printf("done\n");=0A= > }=0A= > @@ -1984,12 +1985,34 @@ init_port(void)=0A= > ports[pid].enabled =3D 1;=0A= > }=0A= > =0A= > +/* When we receive a INT signal, close all ports */=0A= > +static void=0A= > +sigint_handler(__rte_unused int signum)=0A= > +{=0A= > + unsigned portid;=0A= > +=0A= > + printf("Preparing to exit...\n");=0A= =0A= Better to notice user "Signal xxx received, reparing to exit... "=0A= =0A= > + FOREACH_PORT(portid, ports) {=0A= > + if (port_id_is_invalid(portid, ENABLED_WARN))=0A= > + continue;=0A= > + printf("Stopping port %d...", portid);=0A= > + rte_eth_dev_stop(portid);=0A= > + rte_eth_dev_close(portid);=0A= > + printf(" Done\n");=0A= > + }=0A= > + printf("Bye...\n");=0A= =0A= Here why don't call pmd_test_exit()? Any issue with that func?=0A= =0A= Thanks,=0A= Michael=0A= > + exit(0);=0A= > +}=0A= > +=0A= > int=0A= > main(int argc, char** argv)=0A= > {=0A= > int diag;=0A= > uint8_t port_id;=0A= > =0A= > + signal(SIGINT, sigint_handler);=0A= > + signal(SIGTERM, sigint_handler);=0A= > +=0A= > diag =3D rte_eal_init(argc, argv);=0A= > if (diag < 0)=0A= > rte_panic("Cannot init EAL\n");=0A= =0A=