Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/script PR/55529: Soumendra Ganguly: configure the te...
details: https://anonhg.NetBSD.org/src/rev/1ea7e10510b7
branches: trunk
changeset: 936682:1ea7e10510b7
user: christos <christos%NetBSD.org@localhost>
date: Sat Aug 01 17:31:06 2020 +0000
description:
PR/55529: Soumendra Ganguly: configure the terminal in raw mode during
playback so that output postprocessing is not done and playback of programs
using curses does not appear corrupted.
diffstat:
usr.bin/script/script.c | 35 +++++++++++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 2 deletions(-)
diffs (70 lines):
diff -r 92066fe65110 -r 1ea7e10510b7 usr.bin/script/script.c
--- a/usr.bin/script/script.c Sat Aug 01 17:29:00 2020 +0000
+++ b/usr.bin/script/script.c Sat Aug 01 17:31:06 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: script.c,v 1.21 2011/09/06 18:29:56 joerg Exp $ */
+/* $NetBSD: script.c,v 1.22 2020/08/01 17:31:06 christos Exp $ */
/*
* Copyright (c) 1980, 1992, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)script.c 8.1 (Berkeley) 6/6/93";
#endif
-__RCSID("$NetBSD: script.c,v 1.21 2011/09/06 18:29:56 joerg Exp $");
+__RCSID("$NetBSD: script.c,v 1.22 2020/08/01 17:31:06 christos Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -81,6 +81,7 @@
static int quiet, flush;
static const char *fname;
+static int isterm;
static struct termios tt;
__dead static void done(void);
@@ -356,6 +357,34 @@
} while (0/*CONSTCOND*/)
static void
+termset(void)
+{
+ struct termios traw;
+
+ isterm = isatty(STDOUT_FILENO);
+ if (!isterm)
+ return;
+
+ if (tcgetattr(STDOUT_FILENO, &tt) != 0)
+ err(1, "tcgetattr");
+
+ traw = tt;
+ cfmakeraw(&traw);
+ traw.c_lflag |= ISIG;
+ if (tcsetattr(STDOUT_FILENO, TCSANOW, &traw) != 0)
+ err(1, "tcsetattr");
+}
+
+static void
+termreset(void)
+{
+ if (isterm)
+ tcsetattr(STDOUT_FILENO, TCSADRAIN, &tt);
+
+ isterm = 0;
+}
+
+static void
playback(FILE *fp)
{
struct timespec tsi, tso;
@@ -398,6 +427,8 @@
ctime(&tclock));
tsi = tso;
(void)consume(fp, stamp.scr_len, buf, reg);
+ termset();
+ atexit(termreset);
break;
case 'e':
if (!quiet)
Home |
Main Index |
Thread Index |
Old Index