From ler@lerbsd.lerctr.org  Mon Jun 19 08:20:43 2000
Return-Path: <ler@lerbsd.lerctr.org>
Received: from lerbsd.lerctr.org (lerbsd.lerctr.org [207.158.72.45])
	by hub.freebsd.org (Postfix) with ESMTP id 7FF4C37B617
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 19 Jun 2000 08:20:41 -0700 (PDT)
	(envelope-from ler@lerbsd.lerctr.org)
Received: (from ler@localhost)
	by lerbsd.lerctr.org (8.9.3/8.9.3) id KAA89400;
	Mon, 19 Jun 2000 10:20:40 -0500 (CDT)
	(envelope-from ler)
Message-Id: <200006191520.KAA89400@lerbsd.lerctr.org>
Date: Mon, 19 Jun 2000 10:20:40 -0500 (CDT)
From: ler@lerctr.org
Sender: ler@lerbsd.lerctr.org
Reply-To: fdc@columbia.edu, ler@lerctr.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: Curses bug
X-Send-Pr-Version: 3.2

>Number:         19376
>Category:       misc
>Synopsis:       ncurses alters buffering of stdin/stdout and does not restore it.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 19 08:30:01 PDT 2000
>Closed-Date:    Fri Jun 29 20:18:37 PDT 2001
>Last-Modified:  Fri Jun 29 20:22:17 PDT 2001
>Originator:     Frank da Cruz & Larry Rosenman
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
The Kermit Project
Columbia University
>Environment:

C-Kermit 7.0 was released prior to FreeBSD 4.0, and it worked fine on all
FreeBSDs, 2.2.7 through 3.3.  Then when FreeBSD 4.0 came out, a problem
appeared.

When C-Kermit makes a connection (serial, telnet, anything else) and then
transfers a file, it puts up a curses-based file-transfer progress display,
using the normal APIs to initialize curses and then "end the window" when
the display is finished, returning to normal prompt-and-command operation.

When accepting commands at its prompt, C-Kermit must read a character at a
time, since it controls echoing, and acts immediately on certain characters
such as Tab, Esc, question mark, etc, and so puts the terminal in CBREAK
mode.

In FreeBSD 4.0, upon exit from curses, C-Kermit is no longer able to read
a character at a time; it is not given any characters until the user types
a carriage return.  This causes characters not to echo and it prevents
Kermit's keyword and filename completion, menu-on-demand, and command editing
features from working after a file transfer.

Of course after returning from curses, C-Kermit makes the appropriate calls
to put the console back in CBREAK mode, but these don't work in FreeBSD 4.x.
The only workaround is for C-Kermit to call setbuf(stdout,NULL).

The problem was reported to Joerg Wunsch shortly after FreeBSD 4.0 came out,
but it's still in 4.1.

C-Kermit 7.0 is here:

  http://www.columbia.edu/kermit/ckermit.html


>Description:
 sw-bug
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:

From: "Larry Rosenman" <ler@airmail.net>
To: <freebsd-gnats-submit@FreeBSD.org>, <fdc@columbia.edu>,
	"Lawrence Rosenman" <ler@airmail.net>
Cc:  
Subject: Re: misc/19376: ncurses alters buffering of stdin/stdout and does not restore it.
Date: Tue, 11 Jul 2000 14:00:53 -0500

 > I rebuilt my LERBSD box with the current (7/1) ncurses.
 > Please retry C-Kermit...
 >
 It's half fixed.  After starting and then stopping curses, input is no
 longer buffered but output is still buffered.  The current working sources
 are in /home/fdc/kermit.  To build a version without the 4.0-specific setbuf
 hack, use:
 
   make clean
   make freebsd41
 
 (I left a new "wermit" binary there too.)  On the Internet, the same
 source package can be found at:
 
   ftp://kermit.columbia.edu/kermit/test/tar/x.tar.gz
 
 Then to test:
 
   ./wermit
   C-Kermit> telnet localhost
   (log in, start Kermit, put it in server mode, escape back)
   C-Kermit> send <a-file>
 
 This puts up the curses display.  When the transfer is done, you get the
 C-Kermit> prompt back.  At this point, when you type a regular character
 (such
 as letter) it does not echo.  However, if you type a "wakeup" character such
 as "?", you get the expected response, which shows that input is unbuffered.
 If you type a command like "echo foo", the command itself doesn't echo until
 you press the Return key.
 
 So in the latest ncurses, endwin() has restored the previous buffering on
 stdin, but not on stdout.
 
 No other version of Unix, including the other *BSD's, or even pre-4.0
 versions
 of FreeBSD, behave this way.  Or at least *behaved* this way as of about New
 Years Day.  If the same ncurses code is finding its way into new Linuxes,
 etc,
 then maybe they have the same problem but I haven't seen it yet, since I
 haven't done a "build-all" since New Years (it takes about a week to hit
 every platform).
 
 If you could post this as a followup to:
 
   http://www.freebsd.org/cgi/query-pr.cgi?pr=19376
 
 I'd appreciate it -- for some reason my browser won't let me do it.  (Also,
 please include the details of your installation & ncurses version, etc.)
 
 Thanks!
 
 - Frank
 
 ** This is with a CVSUP as of yesterday (7/10/2000 around 20:00 GMT-0500
 (US/Central))
 
 
 

From: "Larry Rosenman" <ler@airmail.net>
To: <freebsd-gnats-submit@FreeBSD.org>, <fdc@columbia.edu>,
	"Lawrence Rosenman" <ler@airmail.net>
Cc:  
Subject: Re: misc/19376: ncurses alters buffering of stdin/stdout and does not restore it.
Date: Fri, 14 Jul 2000 10:21:08 -0500

 There was some discussion on this, and Frank da Cruz 
 has now changed Kermit to use newterm() like Solaris and
 others. 
 
 The fixes imported with 5.1 of ncurses seems to have fixed the
 input side. 
 
 This can be closed, we believe.
 
 Larry Rosenman
 
State-Changed-From-To: open->closed 
State-Changed-By: mikeh 
State-Changed-When: Fri Jun 29 20:18:37 PDT 2001 
State-Changed-Why:  
According to the submitters: a combination of a change to C-Kermit 
plus a new imported version of ncurses, appears to have fixed the 
problem. 


http://www.FreeBSD.org/cgi/query-pr.cgi?pr=19376 
>Unformatted:
