summaryrefslogtreecommitdiff
path: root/usr.bin/script/script.c
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2000-04-16 20:28:55 +0000
committerMarc Espie <espie@cvs.openbsd.org>2000-04-16 20:28:55 +0000
commitbe32b9b318e9af99cfc0e36010eeed1ce873444b (patch)
treefbc146ec1b3fc949a2ac79224ed7e9e5ee6435c9 /usr.bin/script/script.c
parent933418670d8ad6c4c75f2f1e3fd5e341b18caf46 (diff)
Propagate window size changes to slave.
Diffstat (limited to 'usr.bin/script/script.c')
-rw-r--r--usr.bin/script/script.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c
index 4857f675d76..187c4ec7ec9 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: script.c,v 1.11 2000/03/22 20:25:19 ericj Exp $ */
+/* $OpenBSD: script.c,v 1.12 2000/04/16 20:28:54 espie Exp $ */
/* $NetBSD: script.c,v 1.3 1994/12/21 08:55:43 jtc Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)script.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: script.c,v 1.11 2000/03/22 20:25:19 ericj Exp $";
+static char rcsid[] = "$OpenBSD: script.c,v 1.12 2000/04/16 20:28:54 espie Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -81,6 +81,8 @@ __dead void done __P((int));
void fail __P((void));
void finish __P((int));
void scriptflush __P((int));
+ void handlesigwinch __P((int));
+
int
main(argc, argv)
@@ -126,6 +128,7 @@ main(argc, argv)
rtt.c_lflag &= ~ECHO;
(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &rtt);
+ (void)signal(SIGWINCH, handlesigwinch);
(void)signal(SIGCHLD, finish);
child = fork();
if (child < 0) {
@@ -174,6 +177,22 @@ finish(signo)
}
void
+handlesigwinch(signo)
+ int signo;
+{
+ struct winsize win;
+ pid_t pgrp;
+ int save_errno = errno;
+
+ if (ioctl(STDIN_FILENO, TIOCGWINSZ, &win) != -1) {
+ ioctl(slave, TIOCSWINSZ, &win);
+ if (ioctl(slave, TIOCGPGRP, &pgrp) != -1)
+ killpg(pgrp, SIGWINCH);
+ }
+ errno = save_errno;
+}
+
+void
dooutput()
{
struct itimerval value;