Skip to content

Commit

Permalink
clear ONLCR flag for container pty
Browse files Browse the repository at this point in the history
now container pty output log, use \r\n as a newline flag.
This is a windows type, so we need to change it. By clear
ONLCR can reach it.

Signed-off-by: duguhaotian <duguhaotian@gmail.com>
  • Loading branch information
duguhaotian authored and Christian Brauner committed Jun 27, 2018
1 parent 28f7180 commit 40c2312
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lxc/attach.c
Expand Up @@ -24,6 +24,7 @@
#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <termios.h>
#include <grp.h>
#include <pwd.h>
#include <signal.h>
Expand Down Expand Up @@ -979,6 +980,7 @@ static int lxc_attach_terminal(struct lxc_conf *conf,
struct lxc_terminal *terminal)
{
int ret;
struct termios oldtios;

lxc_terminal_init(terminal);

Expand All @@ -988,6 +990,12 @@ static int lxc_attach_terminal(struct lxc_conf *conf,
return -1;
}

ret = lxc_setup_tios(terminal->master, &oldtios);
if (ret < 0) {
SYSERROR("Failed to setup terminal");
return -1;
}

/* Shift ttys to container. */
ret = lxc_terminal_map_ids(conf, terminal);
if (ret < 0) {
Expand Down
6 changes: 6 additions & 0 deletions src/lxc/terminal.c
Expand Up @@ -510,6 +510,7 @@ int lxc_setup_tios(int fd, struct termios *oldtios)
#ifdef IEXTEN
newtios.c_lflag &= ~IEXTEN;
#endif
newtios.c_oflag &= ~ONLCR;
newtios.c_oflag |= OPOST;
newtios.c_cc[VMIN] = 1;
newtios.c_cc[VTIME] = 0;
Expand Down Expand Up @@ -896,6 +897,7 @@ int lxc_terminal_setup(struct lxc_conf *conf)
{
int ret;
struct lxc_terminal *terminal = &conf->console;
struct termios oldtios;

if (terminal->path && strcmp(terminal->path, "none") == 0) {
INFO("No terminal requested");
Expand All @@ -906,6 +908,10 @@ int lxc_terminal_setup(struct lxc_conf *conf)
if (ret < 0)
return -1;

ret = lxc_setup_tios(terminal->master, &oldtios);
if (ret < 0)
return -1;

ret = lxc_terminal_create_log_file(terminal);
if (ret < 0)
goto err;
Expand Down

0 comments on commit 40c2312

Please sign in to comment.