Tags: patch

Dwayne Litzenberger wrote:
> Oh, it uses a different tty?  I think there might be an ioctl that sshpass 
> needs to handle, then.
>
>   

Does the following patch solve the problem?

Shachar
Index: main.c
===================================================================
--- main.c	(revision 28)
+++ main.c	(working copy)
@@ -147,10 +147,17 @@
 
 int handleoutput( int fd );
 
+/* Global variables so that this information be shared with the signal handler */
+static int ourtty; // Our own tty
+static int masterpt;
+
+void window_resize_handler(int signum);
+
 int runprogram( int argc, char *argv[] )
 {
+    struct winsize ttysize; // The size of our tty
     // Create a pseudo terminal for our process
-    int masterpt=getpt();
+    masterpt=getpt();
 
     if( masterpt==-1 ) {
 	perror("Failed to get a pseudo terminal");
@@ -169,6 +176,13 @@
 	return 1;
     }
 
+    ourtty=open("/dev/tty", 0);
+    if( ourtty!=-1 && ioctl( ourtty, TIOCGWINSZ, &ttysize )==0 ) {
+        signal(SIGWINCH, window_resize_handler);
+
+        ioctl( masterpt, TIOCSWINSZ, &ttysize );
+    }
+
     int childpid=fork();
     if( childpid==0 ) {
 	// Child
@@ -333,3 +347,11 @@
 
     write( dstfd, "\n", 1 );
 }
+
+void window_resize_handler(int signum)
+{
+    struct winsize ttysize; // The size of our tty
+
+    if( ioctl( ourtty, TIOCGWINSZ, &ttysize )==0 )
+        ioctl( masterpt, TIOCSWINSZ, &ttysize );
+}

Reply via email to