bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: checkwinsize doesn't work on Solaris due to missing #include for TIO


From: Chet Ramey
Subject: Re: checkwinsize doesn't work on Solaris due to missing #include for TIOCGWINSZ
Date: Mon, 06 Apr 2009 10:47:44 -0400
User-agent: Thunderbird 2.0.0.21 (Macintosh/20090302)

Dan Price wrote:
> [resubmitting, this doesn't seem to have gotten to bug-bash on my first
> try a few weeks ago]
> 
> Configuration Information [Automatically generated, do not change]:
> Machine: i386
> OS: solaris2.11
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
> +-DCONF_OSTYPE='solaris2.11' -DCONF_MACHTYPE='i386-pc-solaris2.11'
> +-DCONF_VENDOR='pc' -DLOCALEDIR='/tmp/share/locale' -DPACKAGE='bash' -DSHELL
> +-DHAVE_CONFIG_H -DSOLARIS   -I.  -I. -I./include -I./lib   -g -O2
> uname output: SunOS xanadu 5.11 snv_108 i86pc i386 i86pc
> Machine Type: i386-pc-solaris2.11
> Bash Version: 3.2
> Patch Level: 48
> Release Status: release
> 
> Description:
> 
> On Solaris/OpenSolaris platforms, I have discovered what I believe is a
> bug in lib/sh/winsize.c.
> 
> I discovered with a debugger that the get_new_window_size() function
> has no effect on Solaris.  In fact, here is what this file looks like if
> you compile it:
> 
> $ dis winsize.o
> disassembly for winsize.o
> section .text
> get_new_window_size()
>     get_new_window_size:     c3                 ret
> 
> That's it-- an empty function.  The problem is that the appropriate header
> file is not getting pulled in, in order to #define TIOCGWINSZ.
> 
> As a result, even with 'shopt -s checkwinsize' set on Solaris, bash
> does not check the win size on suspend of a program, or on program
> exit.  This is massively frustrating, and I know of several Solaris
> users who have switched to zsh as a result of this bug.
> 
> I have not tried bash 4.0, but looking at the source code, it appears
> that the bug is present there as well.
> 
> Repeat-By:
> 
> Fix:
> 
> I added an ifdef clause which looks to see if the HAVE_TERMIOS_H define
> is set, after the #include of config.h.  If it is, then I #include the
> termios.h header file.  This solves the problem, which I confirmed by
> rebuilding and dis'ing the function.  I also ran my recompiled bash
> and confirmed that it now worked correctly.
> 
> Thanks, I appreciate your time.  I hope that I have adequately described
> the problem; feel free to mail me if not.

Try the attached patch and see if it fixes the problem.  I can verify that
the disassembly is very different on Solaris 8 and Solaris 10 after
applying it.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.0-patched/lib/sh/winsize.c        2008-08-12 13:53:51.000000000 
-0400
--- lib/sh/winsize.c    2009-04-06 10:44:20.000000000 -0400
***************
*** 31,44 ****
  #include <sys/ioctl.h>
  
! #if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
! /* For struct winsize on SCO */
! /*   sys/ptem.h has winsize but needs mblk_t from sys/stream.h */
! #  if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH)
! #    if defined (HAVE_SYS_STREAM_H)
! #      include <sys/stream.h>
! #    endif
  #    include <sys/ptem.h>
! #  endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */
! #endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */
  
  #include <stdio.h>
--- 31,57 ----
  #include <sys/ioctl.h>
  
! /* Try to find the definitions of `struct winsize' and TIOGCWINSZ */
! 
! #if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
! #  include <sys/ioctl.h>
! #endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
! 
! #if defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined 
(STRUCT_WINSIZE_IN_SYS_IOCTL)
! #  include <termios.h>
! #endif /* STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
! 
! /* Not in either of the standard places, look around. */
! #if !defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined 
(STRUCT_WINSIZE_IN_SYS_IOCTL)
! #  if defined (HAVE_SYS_STREAM_H)
! #    include <sys/stream.h>
! #  endif /* HAVE_SYS_STREAM_H */
! #  if defined (HAVE_SYS_PTEM_H) /* SVR4.2, at least, has it here */
  #    include <sys/ptem.h>
! #    define _IO_PTEM_H          /* work around SVR4.2 1.1.4 bug */
! #  endif /* HAVE_SYS_PTEM_H */
! #  if defined (HAVE_SYS_PTE_H)  /* ??? */
! #    include <sys/pte.h>
! #  endif /* HAVE_SYS_PTE_H */
! #endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
  
  #include <stdio.h>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]