summaryrefslogtreecommitdiff
path: root/src/stty.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1993-12-22 22:15:29 +0000
committerJim Meyering <jim@meyering.net>1993-12-22 22:15:29 +0000
commit9883bf72802226d20c4de97b217e343725aded9c (patch)
tree9643d9b694a69b08c7538198443b009cc8ec71e8 /src/stty.c
parent7061c33d7b516ca457126be8c9ff6f6dc19f1919 (diff)
downloadcoreutils-9883bf72802226d20c4de97b217e343725aded9c.tar.xz
.
Diffstat (limited to 'src/stty.c')
-rw-r--r--src/stty.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/stty.c b/src/stty.c
index b559398e4..414a2304a 100644
--- a/src/stty.c
+++ b/src/stty.c
@@ -1076,11 +1076,19 @@ set_window_size (rows, cols)
struct winsize win;
if (ioctl (0, TIOCGWINSZ, (char *) &win))
- error (1, errno, "standard input");
- if (rows >= 0)
- win.ws_row = rows;
- if (cols >= 0)
- win.ws_col = cols;
+ {
+ if (errno != EINVAL)
+ error (1, errno, "standard input");
+ win.ws_row = (rows >= 0 ? rows : 0);
+ win.ws_col = (cols >= 0 ? cols : 0);
+ }
+ else
+ {
+ if (rows >= 0)
+ win.ws_row = rows;
+ if (cols >= 0)
+ win.ws_col = cols;
+ }
if (ioctl (0, TIOCSWINSZ, (char *) &win))
error (1, errno, "standard input");
}
@@ -1092,10 +1100,17 @@ display_window_size (fancy)
struct winsize win;
if (ioctl (0, TIOCGWINSZ, (char *) &win))
- error (1, errno, "standard input");
- wrapf (fancy ? "rows %d; columns %d;" : "%d %d\n", win.ws_row, win.ws_col);
- if (!fancy)
- current_col = 0;
+ {
+ if (errno != EINVAL)
+ error (1, errno, "standard input");
+ }
+ else
+ {
+ wrapf (fancy ? "rows %d; columns %d;" : "%d %d\n",
+ win.ws_row, win.ws_col);
+ if (!fancy)
+ current_col = 0;
+ }
}
#endif
@@ -1106,8 +1121,13 @@ screen_columns ()
struct winsize win;
if (ioctl (0, TIOCGWINSZ, (char *) &win))
- error (1, errno, "standard input");
- if (win.ws_col > 0)
+ {
+ /* With Solaris 2.[123], this ioctl fails and errno is set to
+ EINVAL for telnet (but not rlogin) sessions. */
+ if (errno != EINVAL)
+ error (1, errno, "standard input");
+ }
+ else if (win.ws_col > 0)
return win.ws_col;
#endif
if (getenv ("COLUMNS"))