From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id F07F35A57 for ; Thu, 24 Dec 2015 09:12:19 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 24 Dec 2015 00:12:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,472,1444719600"; d="scan'208";a="847610518" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga001.jf.intel.com with ESMTP; 24 Dec 2015 00:12:17 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 24 Dec 2015 00:12:16 -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:12:15 +0800 From: "Qiu, Michael" To: "Wang, Zhihong" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 2/3] examples/l2fwd: Handle SIGINT and SIGTERM in l2fwd Thread-Index: AQHRPfg8ovEry9Q2GE+UeoTNXoGxNQ== Date: Thu, 24 Dec 2015 08:12:14 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E6028622F00215@SHSMSX101.ccr.corp.intel.com> References: <1450900995-84185-1-git-send-email-zhihong.wang@intel.com> <1450900995-84185-3-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 2/3] examples/l2fwd: Handle SIGINT and SIGTERM in l2fwd 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:12:20 -0000 On 12/24/2015 11:07 AM, Zhihong Wang wrote:=0A= > Handle SIGINT and SIGTERM in l2fwd.=0A= >=0A= > Signed-off-by: Zhihong Wang =0A= > ---=0A= > examples/l2fwd/main.c | 25 +++++++++++++++++++++++++=0A= > 1 file changed, 25 insertions(+)=0A= >=0A= > diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c=0A= > index 720fd5a..0594037 100644=0A= > --- a/examples/l2fwd/main.c=0A= > +++ b/examples/l2fwd/main.c=0A= > @@ -44,6 +44,7 @@=0A= > #include =0A= > #include =0A= > #include =0A= > +#include =0A= > =0A= > #include =0A= > #include =0A= > @@ -534,6 +535,27 @@ check_all_ports_link_status(uint8_t port_num, uint32= _t port_mask)=0A= > }=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, nb_ports;=0A= > +=0A= > + printf("Preparing to exit...\n");=0A= =0A= Same here and l3fwd, better to show the reason of this exit.=0A= =0A= Thanks,=0A= Michael=0A= > + nb_ports =3D rte_eth_dev_count();=0A= > + for (portid =3D 0; portid < nb_ports; portid++) {=0A= > + if ((l2fwd_enabled_port_mask & (1 << portid)) =3D=3D 0) {=0A= > + continue;=0A= > + }=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= > + exit(0);=0A= > +}=0A= > +=0A= > int=0A= > main(int argc, char **argv)=0A= > {=0A= > @@ -546,6 +568,9 @@ main(int argc, char **argv)=0A= > unsigned lcore_id, rx_lcore_id;=0A= > unsigned nb_ports_in_mask =3D 0;=0A= > =0A= > + signal(SIGINT, sigint_handler);=0A= > + signal(SIGTERM, sigint_handler);=0A= > +=0A= > /* init EAL */=0A= > ret =3D rte_eal_init(argc, argv);=0A= > if (ret < 0)=0A= =0A=