From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1BC57A052A; Tue, 26 Jan 2021 09:24:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D80101412B0; Tue, 26 Jan 2021 09:24:33 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 1C4631412AF; Tue, 26 Jan 2021 09:24:30 +0100 (CET) IronPort-SDR: 3YpyzuBElaLBTrHwXhXHnP4LzsRGLOqLvKeO5vVsnQaVhcnzYhR+4WWCiRceg7d8azzAtgBY2U iN6FtooZamUQ== X-IronPort-AV: E=McAfee;i="6000,8403,9875"; a="180012720" X-IronPort-AV: E=Sophos;i="5.79,375,1602572400"; d="scan'208";a="180012720" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2021 00:24:29 -0800 IronPort-SDR: 8/8CTxSqUaOSqqaQWRTQZDeIQRhd1F6s2c79UFqJG99eOJPweyxRqlOdJi1GbL4V8LId6OnJhp UXq8J7h8rfIQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,375,1602572400"; d="scan'208";a="353384311" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga003.jf.intel.com with ESMTP; 26 Jan 2021 00:24:29 -0800 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 26 Jan 2021 00:24:29 -0800 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 26 Jan 2021 00:24:29 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 26 Jan 2021 00:24:29 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.108) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Tue, 26 Jan 2021 00:24:28 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j93ol+j/T1ivmx/ClAz2IGpVhAbeWlbJRRCdeh45UG6B/M+051IbxrqIJDVfhx5HnVKOl36ud36kEymGw5bxZeY1wjkge7zL741CTK3IVt8pzFjvHJYLpAZfVeVyMjFZxNuxJx1Goa9h0MsHDxtwJsgBJkQ9rWy/9IAr4WNCs5YGvr2jIRNtob3WsCGO6uCPS834L7QPxATlQUrPxM/+irvKc39ZZrbadgG5vgoKO50TGZ/G3A3N7LzohxCfdaQxa6+Tp3LtOFKezUWNKBrJ9mNH/ddKAQbv6CFZd+zvN7rESYks4JpTtH70X6U5aNL9eTsKoRIZa5U2ev+8K0zjxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5M3IGZvKC/i+r0bARYyS/utYwp6z/4WQGdA0vogkiyU=; b=ba28cQqeoQa9YmP82BZdSHDvovCiZ+8QWjoVAwOL4ASqsxjvBprzaix6IXtH/xXKCjsQfEJQlHVcWubefEChcKifezGFGkcz12QHxu0jmO+B9ZAvDGOdMlcCxrBYsjWZwXPAVj4IyUHRkwROaIm8ZG43rENGbXC1FF3D/NW9nsoCRa3z66sY+29qLygAnF4AhkIxxlmye1LCdOQUqlqRd03NsbuBL9CMhlP8djJnab30VDTSMwWGz1yZR4O6DZtk5bCQbP/5c7GVqbZWzJm7rKFk0PuFKQbXEP4tyU3blI8AVK176VQgimExMQD/0ZYM+dRLRvk/Bj09KCETp29xMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5M3IGZvKC/i+r0bARYyS/utYwp6z/4WQGdA0vogkiyU=; b=mZ5L0ZsCBkEfF7U+KRvbCSdaHDTh425460+nLqc+AGdfHn9hYIhodWPczDiDSwUFtoQBSxnhLeUyL5qWzVHh9OmH0DJ8iRp/tKD45PSJbisE/CorqMAHmWMdumgaqTCvBfFbpbcODymh3ihik0aWktttldJILAh5Kj69sZTwuUc= Received: from CY4PR11MB1750.namprd11.prod.outlook.com (2603:10b6:903:126::8) by CY4PR1101MB2214.namprd11.prod.outlook.com (2603:10b6:910:19::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12; Tue, 26 Jan 2021 08:24:21 +0000 Received: from CY4PR11MB1750.namprd11.prod.outlook.com ([fe80::8fd:c082:f2bc:f6ae]) by CY4PR11MB1750.namprd11.prod.outlook.com ([fe80::8fd:c082:f2bc:f6ae%12]) with mapi id 15.20.3784.016; Tue, 26 Jan 2021 08:24:21 +0000 From: "Li, Xiaoyun" To: "Yu, DapengX" , "Xing, Beilei" , "Lu, Wenzhuo" , "Iremonger, Bernard" , "stephen@networkplumber.org" CC: "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [PATCH v2] app/testpmd: avoid exit without terminal restore Thread-Index: AQHW8spt/LayJIQFn06t5OmjJENWpao47n8AgACNPWCAAAspIIAADFsA Date: Tue, 26 Jan 2021 08:24:20 +0000 Message-ID: References: <20201224035748.67012-1-dapengx.yu@intel.com> <20210125032953.430840-1-dapengx.yu@intel.com> <52b41559f08f4344ae0864e3b67eb030@intel.com> In-Reply-To: <52b41559f08f4344ae0864e3b67eb030@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.37] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5466fe6e-4f93-477d-9eae-08d8c1d3c80a x-ms-traffictypediagnostic: CY4PR1101MB2214: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: TcVilTBn5hetFo3emlNXkoYoOg3gcCXwE7Fw7WVgcSo3RAR6kPL0E3rOwc/jvXxx2yEdiR9I+15n79rfY0XUPgbemPj0MI+oVQ3oNbWrKkIazD/mtVCmNCkTZOES7eTuwd+F5aQFVASemZXUP7E4UwaFnKQrVJCQ8Trj0wUub9hi1JNxmer/zo8rcm0LH+YNdxqT8PWwPSTWQFciNWw/wqVgRaQg7nN7QZubbSfw4d2kik14GHrMNgkJT0bURxv4rk99zOkM8LHDaicAz3s4BKK67VR/JjPvbKfc2AXXPcMWC82xZY+nkKcloOww3n3rxGGFDpD4yMU/EBPr5XuG+CLiHzmcKQpuVfqqi+nUR8hzSJLlztpuUcwQVkSH26an848D4cuNoY/Sav7NRGiiKA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY4PR11MB1750.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(346002)(366004)(136003)(396003)(7696005)(66446008)(66476007)(2906002)(66556008)(64756008)(66946007)(71200400001)(86362001)(54906003)(55016002)(8676002)(76116006)(33656002)(8936002)(186003)(52536014)(316002)(9686003)(26005)(5660300002)(478600001)(53546011)(6506007)(83380400001)(110136005)(4326008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?6xQpekeorQNn78WEu0RpMXJONRFvFjWeZCkcZJMLo0k6T8P0KC1/9B7qwybU?= =?us-ascii?Q?xswsEk+DXxdGDqmUpMTGzhg/Rf0VrLAFemokeneChTy0CH3AhL3AeMTFBOX1?= =?us-ascii?Q?IKQFdw6Bj9ZEHnytTRWMQZ53lcPGC7y7eUpENrqC+BmRd34vy8e6ZYhIsFhE?= =?us-ascii?Q?g9yYi+6EEKfKQW5/xgH+NGa4ULg9tkjobCUQIdPtoiLVQkDQwOAVy7Jk1PTd?= =?us-ascii?Q?+YdpJgjd7NGoWpGVBFFIzqI1k5j1GqYrV0NFZeL75ZUXsNjIy6obr8j+BMOh?= =?us-ascii?Q?OLpvnfXjIwJ0FrxXzgITVWq4FSFKXceD+Ue0DJUSwaHRA1EEVoWxCpTaPl/y?= =?us-ascii?Q?I9CMVxa6+pscJvwsb7VysE13YfByJcGZr9kbB721FOF74N/1S//uT7PbTEQ2?= =?us-ascii?Q?DRbXzymY96lQ9Cd8pI6P/Yb8ORysMf/t6T6/LTZrbRK/FFsOoEu5R/LgrezC?= =?us-ascii?Q?AzP29mRdyh9BPeLovlxGuyTLT+ZiM5CbHOimimwLdJXSzxgMxh5r9nimZzpR?= =?us-ascii?Q?9AlOTF2QW0gBE5HoiWStMMdUBfvE39bg6Kxlw9d6wsnwl1arsVgruWUf7uUL?= =?us-ascii?Q?0dSaRDr7eL5lBxQiPNnJPoAsOgDIGaMk8HQoglA04PIh+BF8Kuq38neKs6Sm?= =?us-ascii?Q?a8PBn9A+qPQiuV106xviV+2QkvMBKjy3+HSwpWrIlej4odXrnyDRCL5xAxqp?= =?us-ascii?Q?Bu1VzQCHuAVj2QorVfVey/y4Fqc6HWa59QepeNFWFFE2FdIiSz88jEDE8Puv?= =?us-ascii?Q?7mXn/lHj6ksLnE3KUg3E/usIf//9naALb0uSYBoym195RWK+sbCLOmowosC9?= =?us-ascii?Q?kpfsKyOnqYiP54O1XHwbSTw7lyOj8AocXNXhfsq3KKFwljS286I3V/ebmvcV?= =?us-ascii?Q?RdIrYjotVBMBfjyn8ZYNm93xl24ImB3MqLp9CHLQApR3yZwI9ncPFZAoEhdq?= =?us-ascii?Q?8c3dBgTJiodkaZDXxLntOhcPx2N2Ai5l/vuhl6zJHTnsLLftEipKoNC8yub0?= =?us-ascii?Q?OPNc2BqhnY22Z8I5m5QVoeIjUEsgXOgTRQsGO3fgHdd7K+1BYnUsMyJiVNl6?= =?us-ascii?Q?mSqhm6vt?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1750.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5466fe6e-4f93-477d-9eae-08d8c1d3c80a X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jan 2021 08:24:20.9835 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Jd0J9HZ9jCfYU/20OWfrOboeyMZPeWF6hG4DNVP4xzjh40ri+1YP/13meqoill4riuOCp5DPxYlw8tjbizPkCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1101MB2214 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2] app/testpmd: avoid exit without terminal restore X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Acked-by: Xiaoyun Li > -----Original Message----- > From: Yu, DapengX > Sent: Tuesday, January 26, 2021 15:44 > To: Li, Xiaoyun ; Xing, Beilei ; Lu, > Wenzhuo ; Iremonger, Bernard > ; stephen@networkplumber.org > Cc: dev@dpdk.org; stable@dpdk.org > Subject: RE: [PATCH v2] app/testpmd: avoid exit without terminal restore >=20 > @Xiaoyun, > Add one more explanation. > even if registers prompt_exit failed, when users type "quit" and then bre= ak from > cmdline_interact(), the ret check will not prevent cmdline_stdin_exit() t= o be > called to restore terminal settings in this patch. >=20 > @Beilei > Can you give comment on this patch v2, so I can move on to resolve this i= ssue > related with this patch. >=20 > -----Original Message----- > From: Yu, DapengX > Sent: Tuesday, January 26, 2021 3:13 PM > To: Li, Xiaoyun ; Xing, Beilei ; Lu, > Wenzhuo ; Iremonger, Bernard > ; stephen@networkplumber.org > Cc: dev@dpdk.org; stable@dpdk.org > Subject: RE: [PATCH v2] app/testpmd: avoid exit without terminal restore >=20 > Hi Xiaoyun, >=20 > For this situation: registering prompt_exit succeed, and user type "quit= " > command to exit testpmd. >=20 > If the second call to cmdline_stdin_exit is not excluded from the code > conditionally, the cmdline_stdin_exit will be called twice; >=20 > 1. the first time: in prompt() > #0 cmdline_stdin_exit (cl=3D0x3638470) > at ../lib/librte_cmdline/cmdline_socket.c:56 > #1 0x000000000051fb62 in prompt () at ../app/test-pmd/cmdline.c:1713= 4 > #2 0x00000000005a4d0f in main (argc=3D2, argv=3D0x7fffffffda70) at .= ./app/test- > pmd/testpmd.c:3849 2. the second time: in exit() . > #0 cmdline_stdin_exit (cl=3D0x3638470) > at ../lib/librte_cmdline/cmdline_socket.c:56 > #1 0x000000000051fb95 in prompt_exit () at ../app/test- > pmd/cmdline.c:17142 > #2 0x00007ffff630fe9c in __run_exit_handlers () from /lib64/libc.so.= 6 > #3 0x00007ffff630ffd0 in exit () from /lib64/libc.so.6 > #4 0x00007ffff62f96aa in __libc_start_main () from /lib64/libc.so.6 > #5 0x00000000004ead2e in _start () >=20 > -----Original Message----- > From: Li, Xiaoyun > Sent: Tuesday, January 26, 2021 2:33 PM > To: Yu, DapengX ; Xing, Beilei ; > Lu, Wenzhuo ; Iremonger, Bernard > ; stephen@networkplumber.org > Cc: dev@dpdk.org; Yu, DapengX ; stable@dpdk.org > Subject: RE: [PATCH v2] app/testpmd: avoid exit without terminal restore >=20 > Hi >=20 > > -----Original Message----- > > From: dapengx.yu@intel.com > > Sent: Monday, January 25, 2021 11:30 > > To: Xing, Beilei ; Li, Xiaoyun > > ; Lu, Wenzhuo ; Iremonger, > > Bernard ; stephen@networkplumber.org > > Cc: dev@dpdk.org; Yu, DapengX ; stable@dpdk.org > > Subject: [PATCH v2] app/testpmd: avoid exit without terminal restore > > > > From: Dapeng Yu > > > > In interactive mode, if testpmd exit by calling rte_exit without > > restore terminal attributes, terminal will not echo keyboard input. > > > > register a function with atexit() in prompt(), when exit() in > > rte_exit() is called, the registered function restores terminal attribu= tes. > > > > Fixes: 5a8fb55c48ab ("app/testpmd: support unidirectional > > configuration") > > Cc: stable@dpdk.org > > > > Signed-off-by: Dapeng Yu > > --- > > app/test-pmd/cmdline.c | 13 +++++++++++-- > > 1 file changed, 11 insertions(+), 2 deletions(-) > > > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index > > 89034c8b7..f7e18ba3d 100644 > > --- a/app/test-pmd/cmdline.c > > +++ b/app/test-pmd/cmdline.c > > @@ -17116,6 +17116,7 @@ cmdline_read_from_file(const char *filename) > > void > > prompt(void) > > { > > +int ret; > > /* initialize non-constant commands */ cmd_set_fwd_mode_init(); > > cmd_set_fwd_retry_mode_init(); @@ -17123,15 +17124,23 @@ prompt(void) > > testpmd_cl =3D cmdline_stdin_new(main_ctx, "testpmd> "); if (testpmd_c= l > > =3D=3D NULL) return; > > + > > +ret =3D atexit(prompt_exit); > > +if (ret !=3D 0) > > +printf("Cannot set exit function for cmdline\n"); > > + > > cmdline_interact(testpmd_cl); > > -cmdline_stdin_exit(testpmd_cl); > > +if (ret !=3D 0) >=20 > Why do you need to check ret here? > Even if registers prompt_exit failed, when users type "quit" and then bre= ak from > cmdline_interact(), cmdline_stdin_exit() should be called to restore term= inal > settings. >=20 > > +cmdline_stdin_exit(testpmd_cl); > > } > > > > void > > prompt_exit(void) > > { > > -if (testpmd_cl !=3D NULL) > > +if (testpmd_cl !=3D NULL) { > > cmdline_quit(testpmd_cl); > > +cmdline_stdin_exit(testpmd_cl); > > +} > > } > > > > static void > > -- > > 2.27.0 >=20 >=20