bug-ncurses
[Top][All Lists]
Advanced

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

Re: ncurses 5.3 (debian linux) - segfault in getch()


From: Thomas Dickey
Subject: Re: ncurses 5.3 (debian linux) - segfault in getch()
Date: Tue, 14 Jan 2003 15:30:44 -0500
User-agent: Mutt/1.3.27i

On Tue, Jan 14, 2003 at 03:07:23PM +0100, Wolfgang Gutjahr wrote:
> Hi,
> 
> after I upgraded to version 5.3 of ncurses, the getch()-function loops 
> (wgetch (), _nc_wgetch (), wgetnstr(), wgetch(),..) and finally 
> segfaults. It is working with stdscr only (see sample below). But my 
> program uses a FILE* as argument for newterm(), which I get from a file 
> descriptor of a telnet session (with fdopen).
> 
> All has worked well with ncurses 5.2.

It's probably related to the version of glibc that you're using more than
to ncurses specifically.

For instance, I don't see any problem (at this moment) with your example
running with 2.1.3, but mixing C++ streams and C stdio hasn't proven to be
reliable simply because the C++ library developers looked at one comment in the
standard as implying that there's no need to make it work (I can dig it out of
my email, but it's been several years).

I'm guessing that for some versions of glibc it works simply because that got
in someone's way, but it doesn't get maintained - and is probably easily
broken.
 
> The following program outputs -1 (correctly) with ncurses 5.2, but 
> segfaults with 5.3. The outcommented version with fd 0 (stdscr) works 
> with both versions:
> 
> #include <curses.h>
> #include <iostream.h>
> 
> int main()
> {
>   FILE* m_pTerm;
>   if ( !(m_pTerm = fopen("junk.txt", "w+")) )
>     {
>       cout << "File open error"  << endl;
>       return 0;       
>     }
> //   if ( !(m_pTerm = fdopen(0, "w+")) )
> //     {
> //       cout << "File open error"  << endl;
> //       return 0;    
> //     }
> 
>   SCREEN* m_pScreen = newterm("vt100",  m_pTerm, m_pTerm);
> 
>   set_term(m_pScreen);
>   initscr();
> 
>   keypad(stdscr, TRUE);
>   nonl();
>   cbreak();
>   noecho();
> 
>   int n = getch();
>   cout << "getch() returned " << n << endl;
> 
>   endwin();
>   delscreen(m_pScreen);
>   fclose(m_pTerm);
> 
> }
> 
> Any explanations and help are highly appreciated.
> 
> best regards,
> Wolfgang
> 
> 
> 
> 
> _______________________________________________
> Bug-ncurses mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-ncurses

-- 
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net




reply via email to

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