Bug 136223

Summary: ee(1) doesn't handle SIGWINCH
Product: Base System Reporter: Alexander Best <alexbestms>
Component: binAssignee: Rong-En Fan <rafan>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 8.0-CURRENT   
Hardware: Any   
OS: Any   

Description Alexander Best 2009-07-01 18:00:09 UTC
when having ee running in an xterm and opening another xterm window ee exits. if running ee in gdb it says: "Program exited normally".

i talked to Paul B. Mahol (onemda at gmail dot com) over at freebsd-questions@ and he believes this to be a bug in ee. this is his analysis of the problem:

"Problems is that ee doesnt handle SIGWINCH properly.
ee on FreeBSD is linked with ncurses but new_curse.c from contrib/ee is
only file that mentions SIGWINCH and that file is not part of
usr.bin/ee/Makefile"

i'm running:
xorg-7.4.2
x11-wm/awesome

cheers.

How-To-Repeat: have ee runnning in an xterm and either open another xterm or resize an existing one.
Comment 1 Alexander Best 2009-07-24 01:49:44 UTC
what's the status of this PR? i think it really should be fixed before
8.0-RELEASE, because it's really frustrating to lose ee's contents everytime a
window gets opened or resized. this will definitely put off user new to
freebsd. shipping an OS with a "broken" editor is pretty much unacceptable.

alex
Comment 2 Alexander Best 2009-10-23 17:41:50 UTC
problem is currently being discussed in this thread:
http://lists.freebsd.org/pipermail/freebsd-hackers/2009-October/029796.html

Eygene Ryabinkin proposed a patch in this post:
http://lists.freebsd.org/pipermail/freebsd-hackers/2009-October/029818.html

i can confirm that the patch solves the problem.

alex
Comment 3 Eygene Ryabinkin 2009-10-24 12:31:19 UTC
Put the patch to the Web for the easiness:
  http://codelabs.ru/fbsd/patches/ncurses/ncurses-properly-handle-SIGWINCH.diff
-- 
Eygene
 _                ___       _.--.   #
 \`.|\..----...-'`   `-._.-'_.-'`   #  Remember that it is hard
 /  ' `         ,       __.--'      #  to read the on-line manual
 )/' _/     \   `-_,   /            #  while single-stepping the kernel.
 `-'" `"\_  ,_.-;_.-\_ ',  fsc/as   #
     _.-'_./   {_.'   ; /           #    -- FreeBSD Developers handbook
    {_.-``-'         {_/            #
Comment 4 dfilter service freebsd_committer 2009-10-26 13:01:41 UTC
Author: rafan
Date: Mon Oct 26 13:01:29 2009
New Revision: 198489
URL: http://svn.freebsd.org/changeset/base/198489

Log:
  Pull upstream patch to fix ee(1) crash when received SIGWINCH:
  
    modify _nc_wgetch() to check for a -1 in the fifo, e.g., after a
    SIGWINCH, and discard that value, to avoid confusing application
    (patch by Eygene Ryabinkin, FreeBSD bin/136223).
  
  PR:		136223
  Submitted by:	Eygene Ryabinkin
  Obtained from:	ncurses-5.7-20091024 snapshot
  MFC after:	3 days

Modified:
  vendor/ncurses/dist/ncurses/base/lib_getch.c

Modified: vendor/ncurses/dist/ncurses/base/lib_getch.c
==============================================================================
--- vendor/ncurses/dist/ncurses/base/lib_getch.c	Mon Oct 26 11:26:49 2009	(r198488)
+++ vendor/ncurses/dist/ncurses/base/lib_getch.c	Mon Oct 26 13:01:29 2009	(r198489)
@@ -476,6 +476,12 @@ _nc_wgetch(WINDOW *win,
 	    /* resizeterm can push KEY_RESIZE */
 	    if (cooked_key_in_fifo()) {
 		*result = fifo_pull(sp);
+		/*
+		 * Get the ERR from queue -- it is from WINCH,
+		 * so we should take it out, the "error" is handled.
+		 */
+		if (fifo_peek(sp) == -1)
+		    fifo_pull(sp);
 		returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
 	    }
 	}
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 5 dfilter service freebsd_committer 2009-10-26 13:04:01 UTC
Author: rafan
Date: Mon Oct 26 13:03:52 2009
New Revision: 198490
URL: http://svn.freebsd.org/changeset/base/198490

Log:
  Merge r198489 from vendor/ncurses/dist:
  
   Pull upstream patch to fix ee(1) crash when received SIGWINCH:
  
     modify _nc_wgetch() to check for a -1 in the fifo, e.g., after a
     SIGWINCH, and discard that value, to avoid confusing application
     (patch by Eygene Ryabinkin, FreeBSD bin/136223).
  
  PR:		136223
  Submitted by:	Eygene Ryabinkin
  Obtained from:	ncurses-5.7-20091024 snapshot
  MFC after:	3 days

Modified:
  head/contrib/ncurses/   (props changed)
  head/contrib/ncurses/ncurses/base/lib_getch.c

Modified: head/contrib/ncurses/ncurses/base/lib_getch.c
==============================================================================
--- head/contrib/ncurses/ncurses/base/lib_getch.c	Mon Oct 26 13:01:29 2009	(r198489)
+++ head/contrib/ncurses/ncurses/base/lib_getch.c	Mon Oct 26 13:03:52 2009	(r198490)
@@ -476,6 +476,12 @@ _nc_wgetch(WINDOW *win,
 	    /* resizeterm can push KEY_RESIZE */
 	    if (cooked_key_in_fifo()) {
 		*result = fifo_pull(sp);
+		/*
+		 * Get the ERR from queue -- it is from WINCH,
+		 * so we should take it out, the "error" is handled.
+		 */
+		if (fifo_peek(sp) == -1)
+		    fifo_pull(sp);
 		returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
 	    }
 	}
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 6 Rong-En Fan freebsd_committer 2009-10-26 13:04:16 UTC
Responsible Changed
From-To: freebsd-bugs->rafan

I'll take it.
Comment 7 Mark Linimon freebsd_committer freebsd_triage 2009-10-28 02:42:52 UTC
State Changed
From-To: open->patched

change has been committed.
Comment 8 dfilter service freebsd_committer 2009-10-30 17:28:54 UTC
Author: rafan
Date: Fri Oct 30 17:28:35 2009
New Revision: 198693
URL: http://svn.freebsd.org/changeset/base/198693

Log:
  MFC r198490
  
   Pull upstream patch to fix ee(1) crash when received SIGWINCH:
  
     modify _nc_wgetch() to check for a -1 in the fifo, e.g., after a
     SIGWINCH, and discard that value, to avoid confusing application
     (patch by Eygene Ryabinkin, FreeBSD bin/136223).
  
  PR:		136223
  Submitted by:	Eygene Ryabinkin
  Obtained from:	ncurses-5.7-20091024 snapshot

Modified:
  stable/8/contrib/ncurses/   (props changed)
  stable/8/contrib/ncurses/ncurses/base/lib_getch.c

Modified: stable/8/contrib/ncurses/ncurses/base/lib_getch.c
==============================================================================
--- stable/8/contrib/ncurses/ncurses/base/lib_getch.c	Fri Oct 30 16:59:58 2009	(r198692)
+++ stable/8/contrib/ncurses/ncurses/base/lib_getch.c	Fri Oct 30 17:28:35 2009	(r198693)
@@ -476,6 +476,12 @@ _nc_wgetch(WINDOW *win,
 	    /* resizeterm can push KEY_RESIZE */
 	    if (cooked_key_in_fifo()) {
 		*result = fifo_pull(sp);
+		/*
+		 * Get the ERR from queue -- it is from WINCH,
+		 * so we should take it out, the "error" is handled.
+		 */
+		if (fifo_peek(sp) == -1)
+		    fifo_pull(sp);
 		returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
 	    }
 	}
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 9 dfilter service freebsd_committer 2009-10-31 12:58:23 UTC
Author: rafan
Date: Sat Oct 31 12:58:13 2009
New Revision: 198716
URL: http://svn.freebsd.org/changeset/base/198716

Log:
  MFC r198490
  
   Pull upstream patch to fix ee(1) crash when received SIGWINCH:
  
     modify _nc_wgetch() to check for a -1 in the fifo, e.g., after a
     SIGWINCH, and discard that value, to avoid confusing application
     (patch by Eygene Ryabinkin, FreeBSD bin/136223).
  
  PR:		136223
  Submitted by:	Eygene Ryabinkin
  Obtained from:	ncurses-5.7-20091024 snapshot
  Approved by:	re (kib@)

Modified:
  releng/8.0/contrib/ncurses/   (props changed)
  releng/8.0/contrib/ncurses/ncurses/base/lib_getch.c

Modified: releng/8.0/contrib/ncurses/ncurses/base/lib_getch.c
==============================================================================
--- releng/8.0/contrib/ncurses/ncurses/base/lib_getch.c	Sat Oct 31 12:26:40 2009	(r198715)
+++ releng/8.0/contrib/ncurses/ncurses/base/lib_getch.c	Sat Oct 31 12:58:13 2009	(r198716)
@@ -476,6 +476,12 @@ _nc_wgetch(WINDOW *win,
 	    /* resizeterm can push KEY_RESIZE */
 	    if (cooked_key_in_fifo()) {
 		*result = fifo_pull(sp);
+		/*
+		 * Get the ERR from queue -- it is from WINCH,
+		 * so we should take it out, the "error" is handled.
+		 */
+		if (fifo_peek(sp) == -1)
+		    fifo_pull(sp);
 		returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
 	    }
 	}
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 10 Rong-En Fan freebsd_committer 2010-04-26 15:39:23 UTC
State Changed
From-To: patched->closed

Problem does not exist in 7. Both 8.x and CURRENT had the fix committed 
last year. Close.