On Wed, Mar 15, 2023 at 10:31:32AM -0700, Stephen Hemminger wrote: > 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.
This was a design choice, not a bug. This design choice is discussable today (at that time, dpdk was also running in baremetal without signals or interrupt). The idea was to behave like a shell, i.e. ctrl-c just clears the current line. We may want to change this behavior (I remember an old discussion where Bruce stated that he would prefer ctrl-c to kill the program), but it will have an impact on all cmdline users, so to me it has to be announced. > > Fixes: af75078fece3 ("first public release") > Signed-off-by: Stephen Hemminger <step...@networkplumber.org> > --- > 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); > } > > -- > 2.39.2 >