From bfd1b83f51e0e4cb77aef2fcb45b888785331cb4 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Thu, 15 Jun 2017 07:01:53 -0700 Subject: [PATCH] conmon: Modify console terminal settings to match kube settings We enable ONLCR on the console to match kube's terminal settings. Signed-off-by: Mrunal Patel --- conmon/conmon.c | 11 +++++++++++ test/ctr.bats | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/conmon/conmon.c b/conmon/conmon.c index dbcf1230..82f8a78c 100644 --- a/conmon/conmon.c +++ b/conmon/conmon.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -640,6 +641,7 @@ static gboolean terminal_accept_cb(int fd, G_GNUC_UNUSED GIOCondition condition, const char *csname = user_data; struct file_t console; int connfd = -1; + struct termios tset; ninfo("about to accept from csfd: %d", fd); connfd = accept4(fd, NULL, NULL, SOCK_CLOEXEC); @@ -657,6 +659,15 @@ static gboolean terminal_accept_cb(int fd, G_GNUC_UNUSED GIOCondition condition, ninfo("console = {.name = '%s'; .fd = %d}", console.name, console.fd); free(console.name); + /* We change the terminal settings to match kube settings */ + if (tcgetattr(console.fd, &tset) == -1) + pexit("Failed to get console terminal settings"); + + tset.c_oflag |= ONLCR; + + if (tcsetattr(console.fd, TCSANOW, &tset) == -1) + pexit("Failed to set console terminal settings"); + /* We only have a single fd for both pipes, so we just treat it as * stdout. stderr is ignored. */ masterfd_stdout = console.fd; diff --git a/test/ctr.bats b/test/ctr.bats index ad6b9e31..953809be 100644 --- a/test/ctr.bats +++ b/test/ctr.bats @@ -241,7 +241,7 @@ function teardown() { logpath="$DEFAULT_LOG_PATH/$pod_id/$ctr_id.log" [ -f "$logpath" ] echo "$logpath :: $(cat "$logpath")" - grep -E "^[^\n]+ stdout here is some output$" "$logpath" + grep -E "^[^\n]+ stdout here is some output" "$logpath" run crioctl pod stop --id "$pod_id" echo "$output"