]> andersk Git - openssh.git/commitdiff
- (djm) OpenBSD CVS Sync
authordjm <djm>
Thu, 16 Jun 2005 03:18:04 +0000 (03:18 +0000)
committerdjm <djm>
Thu, 16 Jun 2005 03:18:04 +0000 (03:18 +0000)
   - jaredy@cvs.openbsd.org 2005/06/07 13:25:23
     [progressmeter.c]
     catch SIGWINCH and resize progress meter accordingly; ok markus dtucker

ChangeLog
progressmeter.c

index d4bae923a8f5cd86a28ad5f5417c80d359f14909..783f39d2f851d07e5a16e20b5f8ec6237592a45d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+20050616
+ - (djm) OpenBSD CVS Sync
+   - jaredy@cvs.openbsd.org 2005/06/07 13:25:23
+     [progressmeter.c]
+     catch SIGWINCH and resize progress meter accordingly; ok markus dtucker
+
+
 20050609
  - (dtucker) [cipher.c openbsd-compat/Makefile.in
    openbsd-compat/openbsd-compat.h openbsd-compat/openssl-compat.{c,h}]
index febe9aad59faadf8715a99368db5f58638703a6c..3cda090616f15fd22524ee668d5e57b6a23ccf00 100644 (file)
@@ -23,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: progressmeter.c,v 1.23 2005/04/28 10:17:56 moritz Exp $");
+RCSID("$OpenBSD: progressmeter.c,v 1.24 2005/06/07 13:25:23 jaredy Exp $");
 
 #include "progressmeter.h"
 #include "atomicio.h"
@@ -42,6 +42,10 @@ static int can_output(void);
 static void format_size(char *, int, off_t);
 static void format_rate(char *, int, off_t);
 
+/* window resizing */
+static void sig_winch(int);
+static void setscreensize(void);
+
 /* updates the progressmeter to reflect the current state of the transfer */
 void refresh_progress_meter(void);
 
@@ -57,6 +61,7 @@ static volatile off_t *counter;       /* progress counter */
 static long stalled;           /* how long we have been stalled */
 static int bytes_per_second;   /* current speed in bytes per second */
 static int win_size;           /* terminal window size */
+static volatile sig_atomic_t win_resized; /* for window resizing */
 
 /* units for format_size */
 static const char unit[] = " KMGT";
@@ -217,6 +222,10 @@ update_progress_meter(int ignore)
 
        save_errno = errno;
 
+       if (win_resized) {
+               setscreensize();
+               win_resized = 0;
+       }
        if (can_output())
                refresh_progress_meter();
 
@@ -228,8 +237,6 @@ update_progress_meter(int ignore)
 void
 start_progress_meter(char *f, off_t filesize, off_t *ctr)
 {
-       struct winsize winsize;
-
        start = last_update = time(NULL);
        file = f;
        end_pos = filesize;
@@ -238,20 +245,12 @@ start_progress_meter(char *f, off_t filesize, off_t *ctr)
        stalled = 0;
        bytes_per_second = 0;
 
-       if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) != -1 &&
-           winsize.ws_col != 0) {
-               if (winsize.ws_col > MAX_WINSIZE)
-                       win_size = MAX_WINSIZE;
-               else
-                       win_size = winsize.ws_col;
-       } else
-               win_size = DEFAULT_WINSIZE;
-       win_size += 1;                                  /* trailing \0 */
-
+       setscreensize();
        if (can_output())
                refresh_progress_meter();
 
        signal(SIGALRM, update_progress_meter);
+       signal(SIGWINCH, sig_winch);
        alarm(UPDATE_INTERVAL);
 }
 
@@ -269,3 +268,25 @@ stop_progress_meter(void)
 
        atomicio(vwrite, STDOUT_FILENO, "\n", 1);
 }
+
+static void
+sig_winch(int sig)
+{
+       win_resized = 1;
+}
+
+static void
+setscreensize(void)
+{
+       struct winsize winsize;
+
+       if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) != -1 &&
+           winsize.ws_col != 0) {
+               if (winsize.ws_col > MAX_WINSIZE)
+                       win_size = MAX_WINSIZE;
+               else
+                       win_size = winsize.ws_col;
+       } else
+               win_size = DEFAULT_WINSIZE;
+       win_size += 1;                                  /* trailing \0 */
+}
This page took 2.095839 seconds and 5 git commands to generate.