1 From c8a9c9c9f6c189164a2eedd0d1e99905cb0a8672 Mon Sep 17 00:00:00 2001
2 From: Christian Brauner <christian.brauner@ubuntu.com>
3 Date: Fri, 10 Nov 2017 19:07:38 +0100
4 Subject: [PATCH 11/13] console: fix console info message
6 Now it will be displayed nicely formatted:
8 a1 login: chb@conventiont|~
12 Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself
14 Ubuntu 17.10 a1 console
18 Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
20 src/lxc/console.c | 54 ++++++++++++++++++++++++++----------------------------
21 1 file changed, 26 insertions(+), 28 deletions(-)
23 diff --git a/src/lxc/console.c b/src/lxc/console.c
24 index eda5be62..e95f5c54 100644
25 --- a/src/lxc/console.c
26 +++ b/src/lxc/console.c
27 @@ -675,26 +675,9 @@ int lxc_console(struct lxc_container *c, int ttynum,
28 struct lxc_tty_state *ts;
31 - istty = isatty(stdinfd);
33 - ret = lxc_setup_tios(stdinfd, &oldtios);
37 - INFO("File descriptor %d does not refer to a tty device", stdinfd);
40 ttyfd = lxc_cmd_console(c->name, &ttynum, &masterfd, c->config_path);
46 - fprintf(stderr, "\n"
47 - "Connected to tty %1$d\n"
48 - "Type <Ctrl+%2$c q> to exit the console, "
49 - "<Ctrl+%2$c Ctrl+%2$c> to enter Ctrl+%2$c itself\n",
50 - ttynum, 'a' + escape - 1);
56 @@ -710,9 +693,12 @@ int lxc_console(struct lxc_container *c, int ttynum,
57 ts->winch_proxy_lxcpath = c->config_path;
58 ts->stdoutfd = stdoutfd;
60 + istty = isatty(stdinfd);
62 lxc_console_winsz(stdinfd, masterfd);
63 lxc_cmd_console_winch(ts->winch_proxy, ts->winch_proxy_lxcpath);
65 + INFO("File descriptor %d does not refer to a tty device", stdinfd);
68 ret = lxc_mainloop_open(&descr);
69 @@ -744,14 +730,34 @@ int lxc_console(struct lxc_container *c, int ttynum,
73 + fprintf(stderr, "\n"
74 + "Connected to tty %1$d\n"
75 + "Type <Ctrl+%2$c q> to exit the console, "
76 + "<Ctrl+%2$c Ctrl+%2$c> to enter Ctrl+%2$c itself\n",
77 + ttynum, 'a' + escape - 1);
80 + ret = lxc_setup_tios(stdinfd, &oldtios);
82 + goto close_mainloop;
85 ret = lxc_mainloop(&descr, -1);
87 ERROR("The mainloop returned an error");
88 - goto close_mainloop;
96 + istty = tcsetattr(stdinfd, TCSAFLUSH, &oldtios);
98 + WARN("%s - Failed to restore terminal properties",
103 lxc_mainloop_close(&descr);
105 @@ -762,13 +768,5 @@ close_fds:
111 - istty = tcsetattr(stdinfd, TCSAFLUSH, &oldtios);
113 - WARN("%s - Failed to restore terminal properties",