Merge pull request #568 from mrunalp/fix_terminal_settings

conmon: Set ONLCR for console
This commit is contained in:
Antonio Murdaca 2017-06-16 10:17:15 +02:00 committed by GitHub
commit 2014f0e14f
2 changed files with 12 additions and 1 deletions

View file

@ -17,6 +17,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/uio.h> #include <sys/uio.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <termios.h>
#include <syslog.h> #include <syslog.h>
#include <unistd.h> #include <unistd.h>
@ -672,6 +673,7 @@ static gboolean terminal_accept_cb(int fd, G_GNUC_UNUSED GIOCondition condition,
const char *csname = user_data; const char *csname = user_data;
struct file_t console; struct file_t console;
int connfd = -1; int connfd = -1;
struct termios tset;
ninfo("about to accept from csfd: %d", fd); ninfo("about to accept from csfd: %d", fd);
connfd = accept4(fd, NULL, NULL, SOCK_CLOEXEC); connfd = accept4(fd, NULL, NULL, SOCK_CLOEXEC);
@ -689,6 +691,15 @@ static gboolean terminal_accept_cb(int fd, G_GNUC_UNUSED GIOCondition condition,
ninfo("console = {.name = '%s'; .fd = %d}", console.name, console.fd); ninfo("console = {.name = '%s'; .fd = %d}", console.name, console.fd);
free(console.name); 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 /* We only have a single fd for both pipes, so we just treat it as
* stdout. stderr is ignored. */ * stdout. stderr is ignored. */
masterfd_stdin = console.fd; masterfd_stdin = console.fd;

View file

@ -241,7 +241,7 @@ function teardown() {
logpath="$DEFAULT_LOG_PATH/$pod_id/$ctr_id.log" logpath="$DEFAULT_LOG_PATH/$pod_id/$ctr_id.log"
[ -f "$logpath" ] [ -f "$logpath" ]
echo "$logpath :: $(cat "$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" run crioctl pod stop --id "$pod_id"
echo "$output" echo "$output"