[lxc-devel] [lxc/master] clear ONLCR flag for container pty
duguhaotian on Github
lxc-bot at linuxcontainers.org
Tue Jun 26 01:40:29 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 3381 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180626/91edbd59/attachment.bin>
-------------- next part --------------
From 21930ebd9d08613863b29d220fd2ff7595fe1c63 Mon Sep 17 00:00:00 2001
From: duguhaotian <duguhaotian at gmail.com>
Date: Tue, 26 Jun 2018 09:57:04 +0800
Subject: [PATCH] clear ONLCR flag for container pty
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 at gmail.com>
---
src/lxc/terminal.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/lxc/terminal.c b/src/lxc/terminal.c
index eb745c5ff..84a411d09 100644
--- a/src/lxc/terminal.c
+++ b/src/lxc/terminal.c
@@ -861,6 +861,7 @@ int lxc_terminal_create_log_file(struct lxc_terminal *terminal)
int lxc_terminal_create(struct lxc_terminal *terminal)
{
int ret;
+ struct termios oldtios;
ret = openpty(&terminal->master, &terminal->slave, terminal->name, NULL, NULL);
if (ret < 0) {
@@ -868,6 +869,18 @@ int lxc_terminal_create(struct lxc_terminal *terminal)
return -1;
}
+ ret = tcgetattr(terminal->master, &oldtios);
+ if (ret < 0) {
+ SYSERROR("Failed to get flag on terminal master");
+ goto err;
+ }
+ oldtios.c_oflag &= ~ONLCR;
+ ret = tcsetattr(terminal->master, TCSAFLUSH, &oldtios);
+ if (ret < 0) {
+ SYSERROR("Failed to set flag on terminal master");
+ goto err;
+ }
+
ret = fcntl(terminal->master, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
SYSERROR("Failed to set FD_CLOEXEC flag on terminal master");
More information about the lxc-devel
mailing list