[Top][All Lists]

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

c++/demo doesn't properly save and restore terminal state

From: John David Anglin
Subject: c++/demo doesn't properly save and restore terminal state
Date: Fri, 17 Aug 2001 15:43:33 -0400 (EDT)

I have been trying to build ncurses-5.2-20010811 with a somewhat experimental
version of gcc 3.0 under vax-dec-ultrix4.3.  In running c++/demo, I found
that the terminal state was clobbered after the program executed.  I set
debug points on _nc_set_tty_mode and _nc_get_tty_mode.  The first break
is here:

(gdb) bt
#0  _nc_set_tty_mode (buf=0x31050) at ../../ncurses/tinfo/lib_ttyflags.c:73
#1  0x15a6a in cbreak () at ../../ncurses/tinfo/lib_raw.c:125
#2  0x5b26 in _ZN13NCursesWindow10initializeEv () at ../../c++/cursesw.cc:153
#3  0x60c7 in _ZN13NCursesWindowC1EP7_win_sti (this=0x30840, win=0x31200, 
    cols=80) at ../../c++/cursesw.cc:259
#4  0x6150 in _ZN13NCursesWindow11ripoff_initEP7_win_sti (w=0x31200, cols=80)
    at ../../c++/cursesw.cc:272
#5  0x16edb in _nc_setupscreen (slines=24, scolumns=80, output=0x2d290)
    at ../../ncurses/base/lib_set_term.c:367
#6  0x2384c in newterm (name=0x7fffc6ed "xterm-r5", ofp=0x2d290, ifp=0x2d27c)
    at ../../ncurses/base/lib_newterm.c:152
#7  0x15881 in initscr () at ../../ncurses/base/lib_initscr.c:65
#8  0x5af9 in _ZN13NCursesWindow10initializeEv () at ../../c++/cursesw.cc:146
#9  0x5cc3 in _ZN13NCursesWindowC1ERP7_win_st (this=0x30800, address@hidden)
    at ../../c++/cursesw.cc:184
#10 0x53ee in _ZN18NCursesApplicationclEv (this=0x2d6a8)
    at ../../c++/cursesapp.cc:128
#11 0x44b2 in main (argc=1, argv=0x7fffc0f4, 2147467516)
    at ../../c++/cursesmain.cc:53

As can be seen, the terminal state is set prior to being saved.  The problem
appears to be that the callback at line 367 of lib_set_term.c occurs before
the calls to def_shell_mode and def_prog_mode.  I made the following patch
and it seems to fix the problem.

J. David Anglin                                  address@hidden
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2001-08-17  John David Anglin  <address@hidden>

        * lib_set_term.c (lib_set_term): Move calls to def_shell_mode and
        def_prog_mode before loop with callbacks.

--- lib_set_term.c.orig Wed Aug 15 12:58:54 2001
+++ lib_set_term.c      Fri Aug 17 15:13:49 2001
@@ -347,6 +347,9 @@
     newscr->_clear = TRUE;
     curscr->_clear = FALSE;
+    def_shell_mode();
+    def_prog_mode();
     for (i = 0, rsp = rippedoff; rsp->line && (i < N_RIPS); rsp++, i++) {
        if (rsp->hook) {
            WINDOW *w;
@@ -381,9 +384,6 @@
     if ((stdscr = newwin(LINES = SP->_lines_avail, scolumns, 0, 0)) == 0)
        return ERR;
     SP->_stdscr = stdscr;
-    def_shell_mode();
-    def_prog_mode();
     return OK;

reply via email to

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