Skip to content

Commit

Permalink
app/testpmd: avoid exit without terminal restore
Browse files Browse the repository at this point in the history
[ upstream commit b3e3d60 ]

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: 5a8fb55 ("app/testpmd: support unidirectional configuration")

Signed-off-by: Dapeng Yu <dapengx.yu@intel.com>
Acked-by: Xiaoyun Li <xiaoyun.li@intel.com>
  • Loading branch information
yudapengx authored and bluca committed Feb 4, 2021
1 parent 2e10839 commit 2f31a5c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/test-pmd/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -17114,22 +17114,31 @@ 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();

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
Expand Down

0 comments on commit 2f31a5c

Please sign in to comment.