From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 23 16:32:41 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 954C61065670 for ; Fri, 23 Oct 2009 16:32:41 +0000 (UTC) (envelope-from a_best01@uni-muenster.de) Received: from zivm-exrelay2.uni-muenster.de (ZIVM-EXRELAY2.UNI-MUENSTER.DE [128.176.192.15]) by mx1.freebsd.org (Postfix) with ESMTP id E661F8FC16 for ; Fri, 23 Oct 2009 16:32:39 +0000 (UTC) X-IronPort-AV: E=Sophos;i="4.44,613,1249250400"; d="scan'208";a="227055604" Received: from zivmaildisp1.uni-muenster.de (HELO ZIVMAILUSER03.UNI-MUENSTER.DE) ([128.176.188.85]) by zivm-relay2.uni-muenster.de with ESMTP; 23 Oct 2009 18:32:38 +0200 Received: by ZIVMAILUSER03.UNI-MUENSTER.DE (Postfix, from userid 149459) id 7C66D1B0750; Fri, 23 Oct 2009 18:32:38 +0200 (CEST) Date: Fri, 23 Oct 2009 18:32:38 +0200 (CEST) From: Alexander Best Sender: Organization: Westfaelische Wilhelms-Universitaet Muenster To: , Dag-Erling Sm??rgrav Message-ID: In-Reply-To: <8gJJDa6kRsCUwxK/zidtHIOFMRw@LbQSLh99U4wa807TkC1GazBU7WI> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: Antony Mawer , freebsd-hackers@freebsd.org, pluknet , ed@freebsd.org, rafan@freebsd.org Subject: Re: help needed to fix contrib/ee crash/exit when receiving SIGWINCH X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Oct 2009 16:32:41 -0000 Eygene Ryabinkin schrieb am 2009-10-23: > Gentlemen, good day. > Fri, Oct 23, 2009 at 02:02:38PM +0200, Dag-Erling Sm??rgrav wrote: > > src/contrib/ee/ee.c in 8: > > in = wgetch(text_win); > > if (in == -1) > > exit(0); /* without this exit ee will go > > into an > > infinite loop if the network > > session detaches */ > > >From the wgetch() man page: > > Programmers concerned about portability should be prepared > > for > > either of two cases: (a) signal receipt does not interrupt > > getch; (b) signal receipt interrupts getch and causes it to > > return ERR with errno set to EINTR. Under the ncurses > > implementation, handled signals never inter??? rupt getch. > Hmm, we can transform this code to the following one: > ----- > errno = 0; > do { > in = wgetch(text_win); > } while (errno == EINTR); > if (in == -1) > exit(0); > ----- > This won't help with FreeBSD's ncurses, but may be other variants > will feel much better with such a event loop variant. > > The real issue, though, is that when a SIGWINCH is caught, wgetch() > > correctly returns KEY_RESIZE, but the next call to wgetch() returns > > -1. > > The next call after that is fine. I suspect the error lies > > somewhere > > inside kgetch() in contrib/ncurses/ncurses/base/lib_getch.c. > The problem should be healed with the attached patch. And you're > partly right: this is kgetch() that is returning ERR for the second > wgetch(), but kgetch() shouldn't be blamed for this -- _nc_wgetch() > should. At least in my opinion ;) > Any views on this? thanks a million. for me the patch works great. :) the sooner it gets committed the better. ;) since this problem is not limited to freebsd it would be nice if somebody could send the patch to the ncurses maintainers so all OSes using ncurses can profit from it. cheers. alex