Date: Fri, 14 Aug 2020 00:55:49 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r364225 - stable/12/usr.bin/script Message-ID: <202008140055.07E0tnLv026099@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Fri Aug 14 00:55:48 2020 New Revision: 364225 URL: https://svnweb.freebsd.org/changeset/base/364225 Log: MFC r364112: script: Minor cleanups. PR: 248377 Modified: stable/12/usr.bin/script/script.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/script/script.c ============================================================================== --- stable/12/usr.bin/script/script.c Fri Aug 14 00:55:23 2020 (r364224) +++ stable/12/usr.bin/script/script.c Fri Aug 14 00:55:48 2020 (r364225) @@ -176,16 +176,16 @@ main(int argc, char *argv[]) if (pflg) playback(fscript); - if ((ttyflg = isatty(STDIN_FILENO)) != 0) { - if (tcgetattr(STDIN_FILENO, &tt) == -1) - err(1, "tcgetattr"); - if (ioctl(STDIN_FILENO, TIOCGWINSZ, &win) == -1) - err(1, "ioctl"); - if (openpty(&master, &slave, NULL, &tt, &win) == -1) + if (tcgetattr(STDIN_FILENO, &tt) == -1 || + ioctl(STDIN_FILENO, TIOCGWINSZ, &win) == -1) { + if (errno != ENOTTY) /* For debugger. */ + err(1, "tcgetattr/ioctl"); + if (openpty(&master, &slave, NULL, NULL, NULL) == -1) err(1, "openpty"); } else { - if (openpty(&master, &slave, NULL, NULL, NULL) == -1) + if (openpty(&master, &slave, NULL, &tt, &win) == -1) err(1, "openpty"); + ttyflg = 1; } if (rawout) @@ -433,9 +433,8 @@ termset(void) struct termios traw; if (tcgetattr(STDOUT_FILENO, &tt) == -1) { - if (errno == EBADF) - err(1, "%d not valid fd", STDOUT_FILENO); - /* errno == ENOTTY */ + if (errno != ENOTTY) /* For debugger. */ + err(1, "tcgetattr"); return; } ttyflg = 1;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008140055.07E0tnLv026099>