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 9D872A052A; Tue, 26 Jan 2021 08:44:10 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4BA11141203; Tue, 26 Jan 2021 08:44:10 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 8CDEC14115F; Tue, 26 Jan 2021 08:44:08 +0100 (CET) IronPort-SDR: BUjFFRg9qjytkF13pByws4qQmmGb24DN8HaywfD5H/tGOMXJUWEiDnSYoy1O1/H3n4/VYS/uOc ICRGRlpa5vLQ== X-IronPort-AV: E=McAfee;i="6000,8403,9875"; a="159039351" X-IronPort-AV: E=Sophos;i="5.79,375,1602572400"; d="scan'208";a="159039351" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2021 23:44:07 -0800 IronPort-SDR: Cg8Ji519MLgeAdJojxN2MRcBXmwllPmN801/iGB71IbpBXnLnrC2Ksg147SVdYsj0wuRouN8Dn +oCDCoBm/JOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,375,1602572400"; d="scan'208";a="472649754" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga001.fm.intel.com with ESMTP; 25 Jan 2021 23:44:07 -0800 Received: from shsmsx602.ccr.corp.intel.com (10.109.6.142) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 25 Jan 2021 23:44:06 -0800 Received: from shsmsx603.ccr.corp.intel.com (10.109.6.143) by SHSMSX602.ccr.corp.intel.com (10.109.6.142) 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 15:44:04 +0800 Received: from shsmsx603.ccr.corp.intel.com ([10.109.6.143]) by SHSMSX603.ccr.corp.intel.com ([10.109.6.143]) with mapi id 15.01.1713.004; Tue, 26 Jan 2021 15:44:04 +0800 From: "Yu, DapengX" To: "Li, Xiaoyun" , "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: AQHW8spjT1qoMP4TKEm2t6asyoZtVKo47n8AgACNPWCAAAspIA== Date: Tue, 26 Jan 2021 07:44:04 +0000 Message-ID: <52b41559f08f4344ae0864e3b67eb030@intel.com> References: <20201224035748.67012-1-dapengx.yu@intel.com> <20210125032953.430840-1-dapengx.yu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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" @Xiaoyun, Add one more explanation. even if registers prompt_exit failed, when users type "quit" and then break= from cmdline_interact(), the ret check will not prevent cmdline_stdin_exit= () to be called to restore terminal settings in this patch. @Beilei Can you give comment on this patch v2, so I can move on to resolve this iss= ue related with this patch. -----Original Message----- From: Yu, DapengX=20 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 Hi Xiaoyun, For this situation: registering prompt_exit succeed, and user type "quit" = command to exit testpmd. If the second call to cmdline_stdin_exit is not excluded from the code cond= itionally, the cmdline_stdin_exit will be called twice; 1. the first time: in prompt() #0 cmdline_stdin_exit (cl=3D0x3638470) at ../lib/librte_cmdline/cmdlin= e_socket.c:56 #1 0x000000000051fb62 in prompt () at ../app/test-pmd/cmdline.c:17134 #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/cmdlin= e_socket.c:56 #1 0x000000000051fb95 in prompt_exit () at ../app/test-pmd/cmdline.c:1= 7142 #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 Hi > -----Original Message----- > From: dapengx.yu@intel.com > Sent: Monday, January 25, 2021 11:30 > To: Xing, Beilei ; Li, Xiaoyun=20 > ; Lu, Wenzhuo ; Iremonger,=20 > Bernard ; stephen@networkplumber.org > Cc: dev@dpdk.org; Yu, DapengX ; stable@dpdk.org > Subject: [PATCH v2] app/testpmd: avoid exit without terminal restore >=20 > From: Dapeng Yu >=20 > In interactive mode, if testpmd exit by calling rte_exit without=20 > restore terminal attributes, terminal will not echo keyboard input. >=20 > register a function with atexit() in prompt(), when exit() in > rte_exit() is called, the registered function restores terminal attribute= s. >=20 > Fixes: 5a8fb55c48ab ("app/testpmd: support unidirectional > configuration") > Cc: stable@dpdk.org >=20 > Signed-off-by: Dapeng Yu > --- > app/test-pmd/cmdline.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) >=20 > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index=20 > 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)=20 > void > prompt(void) > { > +int ret; > /* initialize non-constant commands */ cmd_set_fwd_mode_init();=20 > cmd_set_fwd_retry_mode_init(); @@ -17123,15 +17124,23 @@ prompt(void)=20 > testpmd_cl =3D cmdline_stdin_new(main_ctx, "testpmd> "); if (testpmd_cl= =20 > =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) Why do you need to check ret here? Even if registers prompt_exit failed, when users type "quit" and then break= from cmdline_interact(), cmdline_stdin_exit() should be called to restore = terminal settings. > +cmdline_stdin_exit(testpmd_cl); > } >=20 > void > prompt_exit(void) > { > -if (testpmd_cl !=3D NULL) > +if (testpmd_cl !=3D NULL) { > cmdline_quit(testpmd_cl); > +cmdline_stdin_exit(testpmd_cl); > +} > } >=20 > static void > -- > 2.27.0