diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-07-30 20:57:22 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-10-09 10:28:42 +0200 |
commit | da22bdbc05c0014a0ceb6a14352c30fc2ae277c3 (patch) | |
tree | 469350098f83979ddf0f3d893c69e6db3cd616ba /src/shared/ptyfwd.c | |
parent | c6885f5f36ec299d2ebd5d49d03b2cee37cf8e88 (diff) | |
download | systemd-da22bdbc05c0014a0ceb6a14352c30fc2ae277c3.tar.gz |
ptyfwd: when we can't copy the window size from caller, use $LINES and $COLUMNS
This way users can directly influence the tty size if they like when
nspawn is invoked as a service and thus stdin/stdout/stderr are not
connected to a TTY.
Diffstat (limited to 'src/shared/ptyfwd.c')
-rw-r--r-- | src/shared/ptyfwd.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c index 942c3f31dc..1cb7ea3a19 100644 --- a/src/shared/ptyfwd.c +++ b/src/shared/ptyfwd.c @@ -20,6 +20,7 @@ #include "log.h" #include "macro.h" #include "ptyfwd.h" +#include "terminal-util.h" #include "time-util.h" struct PTYForward { @@ -421,8 +422,17 @@ int pty_forward_new( f->master = master; - if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) >= 0) - (void) ioctl(master, TIOCSWINSZ, &ws); + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0) { + /* If we can't get the resolution from the output fd, then use our internal, regular width/height, + * i.e. something derived from $COLUMNS and $LINES if set. */ + + ws = (struct winsize) { + .ws_row = lines(), + .ws_col = columns(), + }; + } + + (void) ioctl(master, TIOCSWINSZ, &ws); if (!(flags & PTY_FORWARD_READ_ONLY)) { if (tcgetattr(STDIN_FILENO, &f->saved_stdin_attr) >= 0) { |