diff options
author | 2009-11-17 10:56:24 +0100 | |
---|---|---|
committer | 2009-11-17 10:56:24 +0100 | |
commit | 994f905eedc92bc69dbc29b1a967adc72abb69ae (patch) | |
tree | dd609c1c464431255e1098e53e63bc44a4bd36f2 | |
parent | Choose configuration directory (diff) | |
download | lxc-994f905eedc92bc69dbc29b1a967adc72abb69ae.tar.gz lxc-994f905eedc92bc69dbc29b1a967adc72abb69ae.tar.bz2 lxc-994f905eedc92bc69dbc29b1a967adc72abb69ae.zip |
host consoles/ttys in containers
I noticed that container's consoles aren't quite useable
(be it lxc-console or lxc-start with getty bound to /dev/console).
The main problem is a complete lack of window resizing support:
when I resize an xterm window with lxc-start or lxc-console, the
"guest" does not know about that and continues to think that the
terminal is 80x25 still.
Is it just a lack of functionality (missing implementation) or
something problematic?
Ok, the attached patch fixes this.
It moves the 'master' variable out of main function so it's
accessible from the signal handler, sets up SIGWINCH handler
to call a (newly created) winsz() function that gets the
current tty size using TIOCGWINSZ ioctl and if that works,
sets up the pty size using TIOCSWINSZ. That same function
is called at the start as well, when setting up the signal
handler.
Signed-off-By: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-By: Daniel Lezcano <dlezcano@fr.ibm.com>
-rw-r--r-- | src/lxc/lxc_console.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/lxc/lxc_console.c b/src/lxc/lxc_console.c index cff208f..8bdf6b1 100644 --- a/src/lxc/lxc_console.c +++ b/src/lxc/lxc_console.c @@ -36,6 +36,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/poll.h> +#include <sys/ioctl.h> #include <lxc/error.h> #include <lxc/lxc.h> @@ -74,9 +75,22 @@ Options :\n\ .ttynum = -1, }; +static int master = -1; + +static void winsz(void) +{ + struct winsize wsz; + if (ioctl(0, TIOCGWINSZ, &wsz) == 0) + ioctl(master, TIOCSWINSZ, &wsz); +} + +static void sigwinch(int sig) +{ + winsz(); +} + int main(int argc, char *argv[]) { - int master = -1; int wait4q = 0; int err; struct termios tios, oldtios; @@ -120,6 +134,8 @@ int main(int argc, char *argv[]) fprintf(stderr, "\nType <Ctrl+a q> to exit the console\n"); setsid(); + signal(SIGWINCH, sigwinch); + winsz(); err = 0; |