From patchwork Tue Mar 14 17:36:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 125115 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9D00441E93; Tue, 14 Mar 2023 18:37:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9336642B8B; Tue, 14 Mar 2023 18:36:54 +0100 (CET) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mails.dpdk.org (Postfix) with ESMTP id 0FA6940A7E for ; Tue, 14 Mar 2023 18:36:53 +0100 (CET) Received: by mail-pj1-f42.google.com with SMTP id fy10-20020a17090b020a00b0023b4bcf0727so8443033pjb.0 for ; Tue, 14 Mar 2023 10:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; t=1678815412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BJRH6WcJlXgDg7dX8y3KDInXmOHaKNhamhuiDPVDNNI=; b=z7/inMmvcLYeYIix/6SnKIf9u54iBR6wtQjRf8LAQ1PJ8qrRyfkS2nQlW3zkkWHY5z o5FXnWgv52cdL1DjO0RHYGmuTXm1FkJ4yqr9eIXGqhXMmutD4a1uWvlt1wVEs/TLF3kC 99VWZ5guG1oYzZMCINfATXCreXWp0fejdBhFI1QHQHsoI+aTJeOq8Q61AqRvd1iJDxJc yq8hqmcmSWgOo5LBoQb2MHACxxbl7PcO2Oh/Hw+yZe1U0rKnj7rY4NxzsBajKhMiqR4O tgPGSRERbddUNF6FJLwhK6NRZkl1H5M7cLY32hov0NAnvZDJ00dUHiISAc6OSQ2sOhEr z4Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678815412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BJRH6WcJlXgDg7dX8y3KDInXmOHaKNhamhuiDPVDNNI=; b=5CV2mq5GcYY2L7GS31EdPY0683kkl+X4tMnJF/EgURdJWaWJfem9UxtTlup/ELzZrp 4L9nzkd7AsG02IuKRs/Dn2ivDhbcYGjnU+Y4Bh4D8veTwmOOtYfVeSZV0ETgxo7/HTnc CrEHcFloTX4nkOugFdcKPYayQeVyOX2Wugd6WtwzsP/gGuzT1/tYbRqM35YLqMF86a61 FoGVrXyICvF1xNTLAiNWJCBAuKLnChFnMA2dAi1TygebeVD6RFvHxj/EIn+iH1DAIR4Z XnLtMgLXJqpaQmcX7N/64jP2H86K90BVp8pZP1DmdbG7AWFQCs4HtKMpCCpI527ROyGr OCdQ== X-Gm-Message-State: AO0yUKW4fkwaHKjsQ5CvD5TX9LgJB1k3EAVaFfvjbQe/kb/vcZu5VfmG UmLbZQwIlIco0iP45Nk0TSAke6Z4HiwoWVwZDb1xuA== X-Google-Smtp-Source: AK7set8+tRYn6zhzERg2/Et6QXCqVmtVFOYhIxFmBUqpK91kTWkvdChw7QhMzuPGEt09hR+2KLsADg== X-Received: by 2002:a17:902:b187:b0:19f:27fe:95c3 with SMTP id s7-20020a170902b18700b0019f27fe95c3mr9935781plr.41.1678815411958; Tue, 14 Mar 2023 10:36:51 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id q11-20020a170902a3cb00b0019ac9c4f32esm1979970plb.309.2023.03.14.10.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 10:36:51 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Pier Damouny , Aman Singh , Yuying Zhang , Olivier Matz , Ferruh Yigit Subject: [PATCH v3 1/3] testpmd: go back to using cmdline_interact Date: Tue, 14 Mar 2023 10:36:46 -0700 Message-Id: <20230314173648.69528-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314173648.69528-1-stephen@networkplumber.org> References: <20230313171905.67720-1-stephen@networkplumber.org> <20230314173648.69528-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The cmdline library poll function is broken on Windows and was never tested, don't use it. Instead, use sigaction() to cancel read character on Unix OS's and a new helper to cancel I/O on Windows. Fixes: 0fd1386c30c3 ("app/testpmd: cleanup cleanly from signal") Bugzilla ID: 1180 Signed-off-by: Stephen Hemminger Tested-by: Pier Damouny --- app/test-pmd/cmdline.c | 27 ++++++++++++++------------- app/test-pmd/testpmd.c | 11 +++++++++++ lib/cmdline/cmdline.h | 10 ++++++++++ lib/cmdline/cmdline_os_unix.c | 5 +++++ lib/cmdline/cmdline_os_windows.c | 14 ++++++++++++++ lib/cmdline/cmdline_private.h | 2 +- lib/cmdline/version.map | 3 +++ 7 files changed, 58 insertions(+), 14 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 6fa870dc329b..072437d9bfcf 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -66,6 +66,7 @@ #include "cmdline_tm.h" #include "bpf_cmd.h" +static struct cmdline *testpmd_cl; static cmdline_parse_ctx_t *main_ctx; static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head = TAILQ_HEAD_INITIALIZER(driver_commands_head); @@ -13028,26 +13029,26 @@ cmdline_read_from_file(const char *filename) printf("Read CLI commands from %s\n", filename); } +void +prompt_exit(void) +{ + cmdline_cancel(testpmd_cl); + cmdline_quit(testpmd_cl); +} + /* prompt function, called from main on MAIN lcore */ void prompt(void) { - struct cmdline *cl; - - cl = cmdline_stdin_new(main_ctx, "testpmd> "); - if (cl == NULL) + testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); + if (testpmd_cl == NULL) { + fprintf(stderr, + "Failed to create stdin based cmdline context\n"); return; - - /* loop until signal or quit command */ - while (f_quit == 0 && cl_quit == 0) { - int status = cmdline_poll(cl); - - if (status < 0 || status == RDLINE_EXITED) - break; } - cmdline_quit(cl); - cmdline_stdin_exit(cl); + cmdline_interact(testpmd_cl); + cmdline_stdin_exit(testpmd_cl); } void diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 2ce19ed47ab4..5cb6f9252395 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -4469,6 +4469,7 @@ static void signal_handler(int signum __rte_unused) { f_quit = 1; + prompt_exit(); } int @@ -4479,8 +4480,18 @@ main(int argc, char** argv) uint16_t count; int ret; +#ifdef RTE_EXEC_ENV_WINDOWS signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); +#else + /* Want read() not to be restarted on signal */ + struct sigaction action = { + .sa_handler = signal_handler, + }; + + sigaction(SIGINT, &action, NULL); + sigaction(SIGTERM, &action, NULL); +#endif testpmd_logtype = rte_log_register("testpmd"); if (testpmd_logtype < 0) diff --git a/lib/cmdline/cmdline.h b/lib/cmdline/cmdline.h index b14355ef5121..2a1721cf9712 100644 --- a/lib/cmdline/cmdline.h +++ b/lib/cmdline/cmdline.h @@ -60,6 +60,16 @@ int cmdline_poll(struct cmdline *cl); void cmdline_interact(struct cmdline *cl); void cmdline_quit(struct cmdline *cl); + +/** + * This function causes the read() in cmdline_interact to exit. + * + * @param cl + * The command line object. + */ +__rte_experimental +void cmdline_cancel(struct cmdline *cl); + #ifdef __cplusplus } #endif diff --git a/lib/cmdline/cmdline_os_unix.c b/lib/cmdline/cmdline_os_unix.c index 64a945a34fb3..5f9839a15f98 100644 --- a/lib/cmdline/cmdline_os_unix.c +++ b/lib/cmdline/cmdline_os_unix.c @@ -51,3 +51,8 @@ cmdline_vdprintf(int fd, const char *format, va_list op) { return vdprintf(fd, format, op); } + +void +cmdline_cancel(__rte_unused struct cmdline *cl) +{ +} diff --git a/lib/cmdline/cmdline_os_windows.c b/lib/cmdline/cmdline_os_windows.c index 73ed9ba290b8..80863bfc8a00 100644 --- a/lib/cmdline/cmdline_os_windows.c +++ b/lib/cmdline/cmdline_os_windows.c @@ -203,3 +203,17 @@ cmdline_vdprintf(int fd, const char *format, va_list op) return ret; } + +void +cmdline_cancel(struct cmdline *cl) +{ + if (!cl) + return; + + /* force the outstanding read on console to exit */ + if (cl->oldterm.is_console_input) { + HANDLE handle = (HANDLE)_get_osfhandle(cl->s_in); + + CancelIoEx(handle, NULL); + } +} diff --git a/lib/cmdline/cmdline_private.h b/lib/cmdline/cmdline_private.h index a3271c76934a..7ec42ac3c78f 100644 --- a/lib/cmdline/cmdline_private.h +++ b/lib/cmdline/cmdline_private.h @@ -24,7 +24,7 @@ #define RDLINE_HISTORY_MAX_LINE 64 struct rdline { - enum rdline_status status; + volatile enum rdline_status status; /* rdline bufs */ struct cirbuf left; struct cirbuf right; diff --git a/lib/cmdline/version.map b/lib/cmdline/version.map index e3d59aaf8d61..a8a417cd6ff1 100644 --- a/lib/cmdline/version.map +++ b/lib/cmdline/version.map @@ -84,5 +84,8 @@ EXPERIMENTAL { # added in 22.07 cmdline_parse_check; + # added in 23.03 + cmdline_cancel; + local: *; }; From patchwork Tue Mar 14 17:36:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 125116 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1E1F341E93; Tue, 14 Mar 2023 18:37:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE0D742BDA; Tue, 14 Mar 2023 18:36:55 +0100 (CET) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id A7B8141101 for ; Tue, 14 Mar 2023 18:36:53 +0100 (CET) Received: by mail-pj1-f48.google.com with SMTP id j13so406663pjd.1 for ; Tue, 14 Mar 2023 10:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; t=1678815413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M68cgGAccwdlcns1EQOlHuBCNsyevWXyU7u1VYuw/Ms=; b=LUnQs+pLcdx5fH5b3cPqYFU38+x3aEzDhs6aeZ2YHjNPGRgHVECjrcic+LD3RmL5Xn oRSrR36CY23vvdQM+Mp/C/gTryeRtTyLjvUvtfl8ofU17YqEVcgW5Z3tZS/6tvK/iiKb 6Gf98m//6sVDCtEGUPha2lk+dnJkH+15w08FbEqy1cPn0uS1xkZqtHoU7KPi/wzZNic8 29BucyHC27ar1wP+3RorSgcC2oOMMKbS3EU8I2iYeGXfewK2BMUfp77IId0z06kimmsQ 0smimdNAx0SJ7tQqasJdIkfX+tJs3fuWseqOEQUWe+KALa/S0/JcoFxDRbLfGQrjWmsx AL8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678815413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M68cgGAccwdlcns1EQOlHuBCNsyevWXyU7u1VYuw/Ms=; b=QC8wSRBzwIWXhb3cRGqiUSY9hc+iINmRBdcEnxJkX0/J3CZfePlsFyp4qUBtzFHpzm PeoRvFprfZqtISxrXXTImG123ffAOgSstQZAtnJkQDo1Y+xs7lSmamUwnzYytNlWhYGi TV52pckOwlBBu1K/4bRkogz6h3uPT+CzBTL0vwneREH6wuumRXV05c9clIy7BVSao10+ boLDzUZCpu/6Z0kmGe9WB7BQryiLrxOVF7iYO0oqh4Iwpqm+XsQfPFu782ulemimNsr+ dWqgv21gxZ2XnJMm6q+9zoLvqjXZotxvE2kbxqafAhgppA2m1V1ObPsdL84/2hVSNqSs h3Rw== X-Gm-Message-State: AO0yUKVBsJ/hu2hFmEgkE8eGMO2QUsk3E73IltuqSSMm2S2U+hFIjgG7 G7/HYVm+pDn6FfIXT8Oy3P3qjvmVItvj2CLZkoqEkA== X-Google-Smtp-Source: AK7set+y6LR4kfUirirdMtn0qFi4kdNG1vnWyi0FuCPF/x5JNhVDKD9K3wBkuh5+zG7o3O2ej/hZNg== X-Received: by 2002:a17:902:da87:b0:19e:4862:13ab with SMTP id j7-20020a170902da8700b0019e486213abmr43017633plx.69.1678815412969; Tue, 14 Mar 2023 10:36:52 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id q11-20020a170902a3cb00b0019ac9c4f32esm1979970plb.309.2023.03.14.10.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 10:36:52 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Aman Singh , Yuying Zhang Subject: [PATCH v3 2/3] testpmd: use sig_atomic_t for flag Date: Tue, 14 Mar 2023 10:36:47 -0700 Message-Id: <20230314173648.69528-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314173648.69528-1-stephen@networkplumber.org> References: <20230313171905.67720-1-stephen@networkplumber.org> <20230314173648.69528-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Standard conforming signal handling in applications should use sig_atomic_t for flags set by signal handler. https://www.gnu.org/software/libc/manual/html_node/Atomic-Data-Access.html This is really just a fancy way of saying ''int'' but adds to platform portablilty for DPDK. Signed-off-by: Stephen Hemminger --- app/test-pmd/testpmd.c | 6 +----- app/test-pmd/testpmd.h | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 5cb6f9252395..aee926571f53 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -228,11 +228,7 @@ struct rte_eth_xstat_name *xstats_display; unsigned int xstats_display_num; /**< Size of extended statistics to show */ -/* - * In container, it cannot terminate the process which running with 'stats-period' - * option. Set flag to exit stats period loop after received SIGINT/SIGTERM. - */ -volatile uint8_t f_quit; +volatile sig_atomic_t f_quit; /* Quit testpmd from signal */ uint8_t cl_quit; /* Quit testpmd from cmdline. */ /* diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index bdfbfd36d3c5..5c11d4f86301 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -6,6 +6,7 @@ #define _TESTPMD_H_ #include +#include #ifdef RTE_LIB_GRO #include @@ -34,7 +35,7 @@ #define RTE_PORT_HANDLING (uint16_t)3 extern uint8_t cl_quit; -extern volatile uint8_t f_quit; +extern volatile sig_atomic_t f_quit; /* * It is used to allocate the memory for hash key. From patchwork Tue Mar 14 17:36:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 125117 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D01E241E93; Tue, 14 Mar 2023 18:37:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E27C442C24; Tue, 14 Mar 2023 18:36:56 +0100 (CET) Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mails.dpdk.org (Postfix) with ESMTP id E2D8942BAC for ; Tue, 14 Mar 2023 18:36:54 +0100 (CET) Received: by mail-pl1-f173.google.com with SMTP id iw3so547870plb.6 for ; Tue, 14 Mar 2023 10:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; t=1678815414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dKtXYqVpwQcY6GrO3PXl9oT9wgiSfDwbFAHbjsnSxhI=; b=09ntMPGwg8XZKqVhKSrgnyS3hXj7Oxz+xAbt+oGmmz4An3J70exwpVgHdpfs1PTi1n HBeXiWumtMjSUW8+YRAUDL1Q4QgclT8FNhrI1pQHY+UqvjSYL4STFoYciNDNlXyaYaxO HPPz7nOOTeRGT9/hVh8nJBPCY5wBctKsahUfD4U8OpmiQDh3ABU9Q1UEndtJYX8lpyVT jON2cqvrS2X9dFCyO9QtK3OfzWtgicS/3K31JvTRgtS0wMDSYMLE4tHNf7EuktgkvZ8x GgKpiUQp0qmPX7CLL6qVArhF2AvtCcvlFYKi5hKnB8Uv7HIxpjc49adAPcLfp6D4xzLc ZVrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678815414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dKtXYqVpwQcY6GrO3PXl9oT9wgiSfDwbFAHbjsnSxhI=; b=Y66oBCdvagbHloXsuoLqDJ27d8BaGf+/WuOMxC7e8FsTu8E+b7w1maFiK70j7wjnfx A1PkJnCrv+agYY16WdpQGyC9hvM/eNtw1aioIjgYsHFdCYmqB+UOLfEdlh7Sf4yIsEte whwKuG/bJ9USoujaoK7td53DYIH8mFFuLChcNd0Pg9pQsE8u3272Za4GbnhXdf4kHhA8 p4EOJ6og1MjMk6qhqFKipM9Yd1X2MpvCWGrim7OL6+4Jgo4GwD1iUrvTS078sePpEZtL kcoNGIgVPFn/JH1hRXVIeWODh9pV2rspE/dCavPgUi9fpzmNMzMKr/WiTgdcQbQjChcn EbIw== X-Gm-Message-State: AO0yUKWFeM1cFxhPZq6kBERMrQFQiyW+pz6Il4NDMHpQFSw975T9HXnu OYkVhUnPgQBpHvKBk4bU/0CZUWTpBz/loabvw42Ibg== X-Google-Smtp-Source: AK7set8U+/h5+IIJIaIxGc8wO5yHfkWWPLMK6V171JrLPTGGQcHKYqVXLbZ2/5z6UEiiZrA6wt7LMw== X-Received: by 2002:a17:903:283:b0:19e:72cb:ff83 with SMTP id j3-20020a170903028300b0019e72cbff83mr47890337plr.8.1678815413861; Tue, 14 Mar 2023 10:36:53 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id q11-20020a170902a3cb00b0019ac9c4f32esm1979970plb.309.2023.03.14.10.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 10:36:53 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz Subject: [PATCH v3 3/3] testpmd: enable interrupt in interactive mode Date: Tue, 14 Mar 2023 10:36:48 -0700 Message-Id: <20230314173648.69528-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314173648.69528-1-stephen@networkplumber.org> References: <20230313171905.67720-1-stephen@networkplumber.org> <20230314173648.69528-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The setting in terminal handling for both Unix style and Windows was not ensuring that Ctrl-C character would cause interrupt. This is a first release bug. Testpmd interactive mode has always disabled control-c handling on Linux. Fixes: af75078fece3 ("first public release") Signed-off-by: Stephen Hemminger --- lib/cmdline/cmdline_os_unix.c | 3 ++- lib/cmdline/cmdline_os_windows.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/cmdline/cmdline_os_unix.c b/lib/cmdline/cmdline_os_unix.c index 5f9839a15f98..356c5b3f3ca2 100644 --- a/lib/cmdline/cmdline_os_unix.c +++ b/lib/cmdline/cmdline_os_unix.c @@ -16,7 +16,8 @@ terminal_adjust(struct cmdline *cl) tcgetattr(0, &cl->oldterm); memcpy(&term, &cl->oldterm, sizeof(term)); - term.c_lflag &= ~(ICANON | ECHO | ISIG); + term.c_lflag &= ~(ICANON | ECHO); + term.c_lflag |= ISIG; tcsetattr(0, TCSANOW, &term); setbuf(stdin, NULL); diff --git a/lib/cmdline/cmdline_os_windows.c b/lib/cmdline/cmdline_os_windows.c index 80863bfc8a00..8cff3b175747 100644 --- a/lib/cmdline/cmdline_os_windows.c +++ b/lib/cmdline/cmdline_os_windows.c @@ -32,10 +32,10 @@ terminal_adjust(struct cmdline *cl) mode &= ~( ENABLE_LINE_INPUT | /* no line buffering */ ENABLE_ECHO_INPUT | /* no echo */ - ENABLE_PROCESSED_INPUT | /* pass Ctrl+C to program */ ENABLE_MOUSE_INPUT | /* no mouse events */ ENABLE_WINDOW_INPUT); /* no window resize events */ - mode |= ENABLE_VIRTUAL_TERMINAL_INPUT; + mode |= ENABLE_VIRTUAL_TERMINAL_INPUT | + ENABLE_PROCESSED_INPUT; /* Ctrl C processed by the system */ SetConsoleMode(handle, mode); }