Better xterm resize management.
authorviric@llimona
Mon, 08 Oct 2007 11:28:29 +0200
changeset 74 cb3184566c6e
parent 73 9c579a093e7a
child 75 525a97517dc7
Better xterm resize management.
app_term.c
gen_sockets.c
main.h
signals.c
--- a/app_term.c	Mon Oct 08 11:12:42 2007 +0200
+++ b/app_term.c	Mon Oct 08 11:28:29 2007 +0200
@@ -38,6 +38,14 @@
         error("Set close-on-exec failed");
 }
 
+void pass_winsize_to_slave()
+{
+    int res;
+    res = ioctl(0, TIOCGWINSZ, (char *) &app_winsize);
+    if (res >= 0)
+        ioctl(app_stdin, TIOCSWINSZ, (char *) &app_winsize);
+}
+
 static void give_terminal(int parent[], int child[])
 {
     struct termios tios;
--- a/gen_sockets.c	Mon Oct 08 11:12:42 2007 +0200
+++ b/gen_sockets.c	Mon Oct 08 11:28:29 2007 +0200
@@ -49,6 +49,7 @@
         xterm_str = get_xterm_resize_string();
           hex_dump("xterm_resize", xterm_str, strlen(xterm_str));
         send(s, xterm_str, strlen(xterm_str), 0);
+        hex_dump("xterm string sent", xterm_str, strlen(xterm_str));
     }
 }
 
--- a/main.h	Mon Oct 08 11:12:42 2007 +0200
+++ b/main.h	Mon Oct 08 11:28:29 2007 +0200
@@ -70,6 +70,7 @@
 
 /* app_term.c */
 int fork_app(char * const command[]);
+void pass_winsize_to_slave();
 
 /* server_term.c */
 void prepare_user_terminal();
--- a/signals.c	Mon Oct 08 11:12:42 2007 +0200
+++ b/signals.c	Mon Oct 08 11:28:29 2007 +0200
@@ -28,6 +28,8 @@
     char *xterm_str;
     int len;
 
+    pass_winsize_to_slave();
+
     kill(child, val);
 
     /* Resend the xterm string */
@@ -45,20 +47,19 @@
 
 void install_signal_forwarders(int _child)
 {
-  struct sigaction act;
+    struct sigaction act;
 
-  child = _child;
+    child = _child;
 
-  act.sa_handler = forward_signals_to_child_handler;
-  /* Reset the mask */
-  memset(&act.sa_mask,0,sizeof(act.sa_mask));
-  act.sa_flags = 0;
+    act.sa_handler = forward_signals_to_child_handler;
+    sigemptyset(&act.sa_mask);
+    act.sa_flags = 0;
 
-  sigaction(SIGTERM, &act, 0);
-  sigaction(SIGINT, &act, 0);
+    sigaction(SIGTERM, &act, 0);
+    sigaction(SIGINT, &act, 0);
 
-  act.sa_handler = update_window_size;
-  sigaction(SIGWINCH, &act, 0);
+    act.sa_handler = update_window_size;
+    sigaction(SIGWINCH, &act, 0);
 }
 
 static void alarm_handler(int x)
@@ -68,25 +69,24 @@
 
 void program_timeout(int secs)
 {
-  struct sigaction act;
-  struct sigaction *old;
+    struct sigaction act;
+    struct sigaction *old;
 
-  /* Reset the mask */
-  memset(&act.sa_mask,0,sizeof(act.sa_mask));
-  act.sa_flags = 0;
-  act.sa_handler = alarm_handler;
+    sigemptyset(&act.sa_mask);
+    act.sa_flags = 0;
+    act.sa_handler = alarm_handler;
 
-  if (old_alarm_handler_set)
-      old = 0;
-  else
-      old = &old_alarm_handler;
+    if (old_alarm_handler_set)
+        old = 0;
+    else
+        old = &old_alarm_handler;
 
-  sigaction(SIGALRM, &act, old);
+    sigaction(SIGALRM, &act, old);
 
-  old_alarm_handler_set = 1;
-  timeout_timed_out = 0;
+    old_alarm_handler_set = 1;
+    timeout_timed_out = 0;
 
-  alarm(secs);
+    alarm(secs);
 }
 
 int did_timeout_happen()
@@ -109,12 +109,11 @@
 
 void ignore_sighup()
 {
-  struct sigaction act;
+    struct sigaction act;
 
-  act.sa_handler = SIG_IGN;
-  /* Reset the mask */
-  memset(&act.sa_mask,0,sizeof(act.sa_mask));
-  act.sa_flags = 0;
+    act.sa_handler = SIG_IGN;
+    sigemptyset(&act.sa_mask);
+    act.sa_flags = 0;
 
-  sigaction(SIGHUP, &act, 0);
+    sigaction(SIGHUP, &act, 0);
 }