]> granicus.if.org Git - sudo/commitdiff
Prefer newer TIOCGWINSZ ioctl to old TIOCGSIZE
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 2 Oct 2010 21:07:27 +0000 (17:07 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 2 Oct 2010 21:07:27 +0000 (17:07 -0400)
--HG--
branch : 1.7

exec_pty.c
lbuf.c

index c0dd068a3b41f7a40acfe5e91651abe163196391..9c152d8f6e22b498d837799c8abd0ac031703d91 100644 (file)
 #define TERM_RAW       1
 
 /* Compatibility with older tty systems. */
-#if !defined(TIOCGSIZE) && defined(TIOCGWINSZ)
-# define TIOCGSIZE     TIOCGWINSZ
-# define TIOCSSIZE     TIOCSWINSZ
-# define ttysize       winsize
-# define ts_cols       ws_col
+#if !defined(TIOCGWINSZ) && defined(TIOCGSIZE)
+# define TIOCGWINSZ    TIOCGSIZE
+# define TIOCSWINSZ    TIOCSSIZE
+# define winsize       ttysize
+# define ws_cols       ts_col
 #endif
 
 struct io_buffer {
@@ -1040,12 +1040,12 @@ sync_ttysize(src, dst)
     int src;
     int dst;
 {
-#ifdef TIOCGSIZE
-    struct ttysize tsize;
+#ifdef TIOCGWINSZ
+    struct winsize wsize;
     pid_t pgrp;
 
-    if (ioctl(src, TIOCGSIZE, &tsize) == 0) {
-           ioctl(dst, TIOCSSIZE, &tsize);
+    if (ioctl(src, TIOCGWINSZ, &wsize) == 0) {
+           ioctl(dst, TIOCSWINSZ, &wsize);
            if ((pgrp = tcgetpgrp(dst)) != -1)
                killpg(pgrp, SIGWINCH);
     }
diff --git a/lbuf.c b/lbuf.c
index 3b4bd410f0dd55144d14d71859bfb311a42f9bfc..4ec2262189c353d763bc772858fc8c281ba676b6 100644 (file)
--- a/lbuf.c
+++ b/lbuf.c
 #include "sudo.h"
 #include "lbuf.h"
 
-#if !defined(TIOCGSIZE) && defined(TIOCGWINSZ)
-# define TIOCGSIZE     TIOCGWINSZ
-# define ttysize       winsize
-# define ts_cols       ws_col
+/* Compatibility with older tty systems. */
+#if !defined(TIOCGWINSZ) && defined(TIOCGSIZE)
+# define TIOCGWINSZ    TIOCGSIZE
+# define winsize       ttysize
+# define ws_cols       ts_col
 #endif
 
 int
@@ -65,11 +66,11 @@ get_ttycols()
 {
     char *p;
     int cols;
-#ifdef TIOCGSIZE
-    struct ttysize win;
+#ifdef TIOCGWINSZ
+    struct winsize wsize;
 
-    if (ioctl(STDERR_FILENO, TIOCGSIZE, &win) == 0 && win.ts_cols != 0)
-       return((int)win.ts_cols);
+    if (ioctl(STDERR_FILENO, TIOCGWINSZ, &wsize) == 0 && wsize.ws_cols != 0)
+       return((int)wsize.ws_cols);
 #endif
 
     /* Fall back on $COLUMNS. */