static TTY mode, oldmode, original;
static bool opt_c; /* set control-chars */
static TTY mode, oldmode, original;
static bool opt_c; /* set control-chars */
(void) fprintf(stderr, "\n");
fflush(stderr);
ExitProgram(EXIT_FAILURE);
(void) fprintf(stderr, "\n");
fflush(stderr);
ExitProgram(EXIT_FAILURE);
#ifdef TAB3
if (oldmode.c_oflag & (TAB3 | ONLCR | OCRNL | ONLRET)) {
oldmode.c_oflag &= (TAB3 | ONLCR | OCRNL | ONLRET);
#ifdef TAB3
if (oldmode.c_oflag & (TAB3 | ONLCR | OCRNL | ONLRET)) {
oldmode.c_oflag &= (TAB3 | ONLCR | OCRNL | ONLRET);
obsolete(argv);
noinit = noset = quiet = Sflag = sflag = showterm = 0;
while ((ch = getopt(argc, argv, "a:cd:e:Ii:k:m:p:qQSrsVw")) != -1) {
obsolete(argv);
noinit = noset = quiet = Sflag = sflag = showterm = 0;
while ((ch = getopt(argc, argv, "a:cd:e:Ii:k:m:p:qQSrsVw")) != -1) {
- if (GET_TTY(STDERR_FILENO, &mode) < 0 &&
- GET_TTY(STDOUT_FILENO, &mode) < 0) {
+ if (!get_mode(STDERR_FILENO) &&
+ !get_mode(STDOUT_FILENO) &&
+ !get_mode(STDIN_FILENO) &&
+ !get_mode(open("/dev/tty", O_RDWR))) {
if (WINSIZE_ROWS(win) == 0 &&
WINSIZE_COLS(win) == 0 &&
tlines > 0 && tcolumns > 0) {
WINSIZE_ROWS(win) = (unsigned short) tlines;
WINSIZE_COLS(win) = (unsigned short) tcolumns;
if (WINSIZE_ROWS(win) == 0 &&
WINSIZE_COLS(win) == 0 &&
tlines > 0 && tcolumns > 0) {
WINSIZE_ROWS(win) = (unsigned short) tlines;
WINSIZE_COLS(win) = (unsigned short) tcolumns;
/* Set the modes if they've changed. */
if (memcmp(&mode, &oldmode, sizeof(mode))) {
/* Set the modes if they've changed. */
if (memcmp(&mode, &oldmode, sizeof(mode))) {