From: espie Date: Sun, 16 Apr 2000 20:28:54 +0000 (+0000) Subject: Propagate window size changes to slave. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6f6caaa952d199863f30ad71ffd76c0691814fff;p=openbsd Propagate window size changes to slave. --- 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 @@ -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) { @@ -173,6 +176,22 @@ finish(signo) errno = save_errno; } +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() {