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 BAB2BA0A0B for ; Mon, 25 Jan 2021 04:30:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A40C0140DEB; Mon, 25 Jan 2021 04:30:14 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 1FDE1140DE4; Mon, 25 Jan 2021 04:30:11 +0100 (CET) IronPort-SDR: hlSj/KwqK3gW8s5x5AYmcR9s2+ud4NXiwAmoaLg7WPhSU0nCZn/AXrqwu0xCa1fgyUL2raaxjY ydiZCSBa5c0w== X-IronPort-AV: E=McAfee;i="6000,8403,9874"; a="178879466" X-IronPort-AV: E=Sophos;i="5.79,372,1602572400"; d="scan'208";a="178879466" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2021 19:30:10 -0800 IronPort-SDR: WO46HNCVpdRLCr2IRvvDfMiw+nK/5Dw/AHIJe4b80w554VF2BE7Ta+YPebTPi761pRfKx08cfR k4Jh1PlGUmDg== X-IronPort-AV: E=Sophos;i="5.79,372,1602572400"; d="scan'208";a="387131833" Received: from unknown (HELO localhost.localdomain) ([10.240.183.93]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2021 19:30:08 -0800 From: dapengx.yu@intel.com To: beilei.xing@intel.com, xiaoyun.li@intel.com, wenzhuo.lu@intel.com, bernard.iremonger@intel.com, stephen@networkplumber.org Cc: dev@dpdk.org, Dapeng Yu , stable@dpdk.org Date: Mon, 25 Jan 2021 11:29:53 +0800 Message-Id: <20210125032953.430840-1-dapengx.yu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201224035748.67012-1-dapengx.yu@intel.com> References: <20201224035748.67012-1-dapengx.yu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v2] app/testpmd: avoid exit without terminal restore X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 attributes. 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 = cmdline_stdin_new(main_ctx, "testpmd> "); if (testpmd_cl == NULL) return; + + ret = atexit(prompt_exit); + if (ret != 0) + printf("Cannot set exit function for cmdline\n"); + cmdline_interact(testpmd_cl); - cmdline_stdin_exit(testpmd_cl); + if (ret != 0) + cmdline_stdin_exit(testpmd_cl); } void prompt_exit(void) { - if (testpmd_cl != NULL) + if (testpmd_cl != NULL) { cmdline_quit(testpmd_cl); + cmdline_stdin_exit(testpmd_cl); + } } static void -- 2.27.0