aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/script
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2020-08-07 18:48:56 +0000
committerMark Johnston <markj@FreeBSD.org>2020-08-07 18:48:56 +0000
commit69bc4fa916a9bd02b44e1e7f8814b12437592401 (patch)
tree3d70af097420ebd182f3c3b6fa2e84659e30e82c /usr.bin/script
parentc34e4b5c63f57c3c4d55b3ba419fc563ee4eabf0 (diff)
Notes
Diffstat (limited to 'usr.bin/script')
-rw-r--r--usr.bin/script/script.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c
index d05bd3d6040ac..8d22ea4251e75 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -428,6 +428,33 @@ consume(FILE *fp, off_t len, char *buf, int reg)
} while (0/*CONSTCOND*/)
static void
+termset(void)
+{
+ struct termios traw;
+
+ if (tcgetattr(STDOUT_FILENO, &tt) == -1) {
+ if (errno == EBADF)
+ err(1, "%d not valid fd", STDOUT_FILENO);
+ /* errno == ENOTTY */
+ return;
+ }
+ ttyflg = 1;
+ traw = tt;
+ cfmakeraw(&traw);
+ traw.c_lflag |= ISIG;
+ (void)tcsetattr(STDOUT_FILENO, TCSANOW, &traw);
+}
+
+static void
+termreset(void)
+{
+ if (ttyflg) {
+ tcsetattr(STDOUT_FILENO, TCSADRAIN, &tt);
+ ttyflg = 0;
+ }
+}
+
+static void
playback(FILE *fp)
{
struct timespec tsi, tso;
@@ -470,8 +497,11 @@ playback(FILE *fp)
ctime(&tclock));
tsi = tso;
(void)consume(fp, stamp.scr_len, buf, reg);
+ termset();
+ atexit(termreset);
break;
case 'e':
+ termreset();
if (!qflg)
(void)printf("\nScript done on %s",
ctime(&tclock));