From: Todd C. Miller Date: Sat, 2 Oct 2010 21:07:27 +0000 (-0400) Subject: Prefer newer TIOCGWINSZ ioctl to old TIOCGSIZE X-Git-Tag: SUDO_1_7_5~135 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b1cae3682d7c690501b821f21e72c4b835a27854;p=sudo Prefer newer TIOCGWINSZ ioctl to old TIOCGSIZE --HG-- branch : 1.7 --- diff --git a/exec_pty.c b/exec_pty.c index c0dd068a3..9c152d8f6 100644 --- a/exec_pty.c +++ b/exec_pty.c @@ -72,11 +72,11 @@ #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 3b4bd410f..4ec226218 100644 --- a/lbuf.c +++ b/lbuf.c @@ -54,10 +54,11 @@ #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. */