The attached patch fixes resizing, at least on Linux.

Note that I got rid of the -D_XOPEN_SOURCE in debian/rules.
That define makes signal() misbehave; in particular I was seeing
in gdb that both the SIGCHLD and SIGWINCH signal handlers were
being called when the terminal was resized. Removing the define
fixed that. Still, using sigaction (like script does) might be
better.

Also, I don't really understand why resize() does the TIOCSWINSZ
ioctl on master, not slave. But calling the ioctl on slave did
not propigate the resize to the slave, while master does. Odd.

-- 
see shy jo
diff -ur old/ttyrec-1.0.8/debian/rules ttyrec-1.0.8/debian/rules
--- old/ttyrec-1.0.8/debian/rules       2010-01-11 15:47:38.000000000 -0500
+++ ttyrec-1.0.8/debian/rules   2010-01-11 22:25:36.000000000 -0500
@@ -12,7 +12,7 @@
 build-stamp:
        dh_testdir
 
-       $(MAKE) CFLAGS="-O2 -Wall -DSVR4 -D_XOPEN_SOURCE=500"
+       $(MAKE) CFLAGS="-O2 -Wall -DSVR4"
 
        uudecode debian/sample1.tty.uue
 
diff -ur old/ttyrec-1.0.8/ttyrec.c ttyrec-1.0.8/ttyrec.c
--- old/ttyrec-1.0.8/ttyrec.c   2010-01-11 15:47:38.000000000 -0500
+++ ttyrec-1.0.8/ttyrec.c       2010-01-11 22:24:40.000000000 -0500
@@ -121,6 +121,7 @@
        extern int optind;
        int ch;
        void finish();
+       void resize();
        char *getenv();
        char *command = NULL;
 
@@ -178,6 +179,9 @@
                else
                        doshell(command);
        }
+       else {
+               (void) signal(SIGWINCH, resize);
+       }
        doinput();
 
        return 0;
@@ -219,6 +223,13 @@
                done();
 }
 
+void
+resize()
+{
+       (void) ioctl(0, TIOCGWINSZ, (char *)&win);
+       (void) ioctl(master, TIOCSWINSZ, (char *)&win);
+}
+
 struct linebuf {
     char str[BUFSIZ + 1]; /* + 1 for an additional NULL character.*/
     int len;

Attachment: signature.asc
Description: Digital signature

Reply via email to