From nobody@FreeBSD.org  Mon Jul  2 14:14:03 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 7D4711065673
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  2 Jul 2012 14:14:03 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 68F008FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  2 Jul 2012 14:14:03 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q62EE3T7039693
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 2 Jul 2012 14:14:03 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q62EE3SO039692;
	Mon, 2 Jul 2012 14:14:03 GMT
	(envelope-from nobody)
Message-Id: <201207021414.q62EE3SO039692@red.freebsd.org>
Date: Mon, 2 Jul 2012 14:14:03 GMT
From: David Shao <davshao@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Possible r237738 libedit regression resizing windows in terminal programs
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         169603
>Category:       kern
>Synopsis:       Possible r237738 libedit regression resizing windows in terminal programs
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pfg
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 02 14:20:07 UTC 2012
>Closed-Date:    Mon Jul 09 16:35:04 UTC 2012
>Last-Modified:  Mon Jul 09 16:35:04 UTC 2012
>Originator:     David Shao
>Release:        FreeBSD 9.0-STABLE amd64
>Organization:
>Environment:
FreeBSD randomfbsd 9.0-STABLE FreeBSD 9.0-STABLE #0 r237980: Mon Jul  2 04:30:31 PDT 2012     root@randomfbsd:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
Some update between r237683 and r237740 has caused a regression with xfce4's Terminal program:  An attempt to resize a window by dragging a corner results in the window immediately closing.

I have reproduced this on a Pentium 4 machine with an old ati radeon 9000 era card and on newer machines with radeon 4xxxx cards.  There is one exception I have noted: a Terminal window with the results of
svn log | less
can be resized without closing.

While I have not exactly bisected the problem to r237738, this regression is similar to one I have reported for DragonFly BSD after a bisection to an update to libedit.  The identical symptoms lead me to believe the problem will be manifested beyond xfce4's Terminal and beyond the radeon cards tested.
>How-To-Repeat:
Update FreeBSD 9.0-STABLE to r237740 or later and resize a window of xfce4's Terminal program.
>Fix:


>Release-Note:
>Audit-Trail:

From: Pedro Giffuni <pfg@freebsd.org>
To: bug-followup@FreeBSD.org, davshao@gmail.com
Cc:  
Subject: Re: kern/169603: Possible r237738 libedit regression resizing windows in terminal programs
Date: Tue, 3 Jul 2012 20:06:48 -0700 (PDT)

 Hello;=0A=0AI've been looking for some probable connection here but=0AI am =
 unable to find it. We would need to find a library=0Aor program related to =
 the problem that uses libedit.=0APlease check to see if you have *.core fil=
 es in your=0Ahome directory.=0A=0AI did find reports on a similar behavior =
 on linux but=0Ait appears to be related with X.=0A=0AYou can of course reve=
 rt r237448, which only affects=0Alibedit, to see if that is the culprit.

From: Peter Jeremy <peter@rulingia.com>
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org,
        David Shao <davshao@gmail.com>
Cc:  
Subject: Re: kern/169603: Possible r237738 libedit regression resizing
 windows in terminal programs
Date: Thu, 5 Jul 2012 08:21:01 +1000

 --aVD9QWMuhilNxW9f
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 I am seeing a similar problem with 9-stable/amd64 (r237995) - sh(1)
 now exits if I change the window size (ssh'ing to the target system
 within an xterm).
 
 ktrace output looks like:
   1766 sh       GIO   fd 2 wrote 2 bytes
        "# "
   1766 sh       RET   write 2
   1766 sh       CALL  ioctl(0,TIOCGETA,0x801020364)
   1766 sh       RET   ioctl 0
   1766 sh       CALL  ioctl(0,TIOCSETAW,0x801020338)
   1766 sh       RET   ioctl 0
   1766 sh       CALL  read(0,0x7fffffffda8f,0x1)
   1766 sh       RET   read -1 errno 4 Interrupted system call
   1766 sh       PSIG  SIGWINCH caught handler=3D0x417d10 mask=3D0x0 code=3D=
 0x10006
   1766 sh       CALL  sigreturn(0x7fffffffd600)
   1766 sh       RET   sigreturn JUSTRETURN
   1766 sh       CALL  ioctl(0,TIOCSETAW,0x80102030c)
   1766 sh       RET   ioctl 0
   1766 sh       CALL  setpgid(0,0x6e6)
   1766 sh       RET   setpgid -1 errno 1 Operation not permitted
   1766 sh       CALL  ioctl(0xa,TIOCSPGRP,0x7fffffffda74)
   1766 sh       RET   ioctl 0
   1766 sh       CALL  close(0xa)
   1766 sh       RET   close 0
   1766 sh       CALL  exit(0)
 
 Reverting r237738 (the MFC of r237448), as suggested by pfg@, fixes the
 problem.  Unfortunately this is quite a large commit and I haven't
 looked into the specific change that breaks SIGWINCH handling.
 
 --=20
 Peter Jeremy
 
 --aVD9QWMuhilNxW9f
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.19 (FreeBSD)
 
 iEYEARECAAYFAk/0wc0ACgkQ/opHv/APuIfuPQCgkyndvzwlYXBsVF3N55+r1V/P
 6pUAn326qQ1i9kI9HkbTHX1Z6mEL/XWv
 =62+O
 -----END PGP SIGNATURE-----
 
 --aVD9QWMuhilNxW9f--
Responsible-Changed-From-To: freebsd-bugs->pfg 
Responsible-Changed-By: pfg 
Responsible-Changed-When: Wed Jul 4 22:46:20 UTC 2012 
Responsible-Changed-Why:  
I caused it, I'll fix it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169603 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/169603: commit references a PR
Date: Fri,  6 Jul 2012 16:44:11 +0000 (UTC)

 Author: pfg
 Date: Fri Jul  6 16:43:56 2012
 New Revision: 238173
 URL: http://svn.freebsd.org/changeset/base/238173
 
 Log:
   Fix issue resizing bin/sh
   
   This partially reverts some changes from r237448 that are causing
   breakage when resizing under bin/sh .
   
   Reverted changes from NetBSD are:
   
   Mar 10 20:46:15 2009 - editline.3 read.c
   make el_gets set the count to -1 on error to distinguish between EOF and
   error.
   
   Feb 19 15:20:22 2009 - read.c sig.c sig.h
   reset and redraw on sigcont. From Anon Ymous.
   
   Feb 15 21:24:13 2009
   don't restart on EINTR, instead return NULL immediately. From Anon Ymous
   
   PR:		169603
   Reported by:	Peter Jeremy, David Shao
   MFC after:	3 days
 
 Modified:
   head/lib/libedit/editline.3
   head/lib/libedit/el.h
   head/lib/libedit/read.c
   head/lib/libedit/sig.c
   head/lib/libedit/sig.h
 
 Modified: head/lib/libedit/editline.3
 ==============================================================================
 --- head/lib/libedit/editline.3	Fri Jul  6 15:57:03 2012	(r238172)
 +++ head/lib/libedit/editline.3	Fri Jul  6 16:43:56 2012	(r238173)
 @@ -162,11 +162,6 @@ is modified to contain the number of cha
  Returns the line read if successful, or
  .Dv NULL
  if no characters were read or if an error occurred.
 -If an error occurred,
 -.Fa count
 -is set to \-1 and
 -.Dv errno
 -contains the error code that caused it.
  The return value may not remain valid across calls to
  .Fn el_gets
  and must be copied if the data is to be retained.
 
 Modified: head/lib/libedit/el.h
 ==============================================================================
 --- head/lib/libedit/el.h	Fri Jul  6 15:57:03 2012	(r238172)
 +++ head/lib/libedit/el.h	Fri Jul  6 16:43:56 2012	(r238173)
 @@ -115,7 +115,6 @@ struct editline {
  	FILE		 *el_errfile;	/* Stdio stuff			*/
  	int		  el_infd;	/* Input file descriptor	*/
  	int		  el_flags;	/* Various flags.		*/
 -	int		  el_errno;	/* Local copy of errno		*/
  	coord_t		  el_cursor;	/* Cursor location		*/
  	char		**el_display;	/* Real screen image = what is there */
  	char		**el_vdisplay;	/* Virtual screen image = what we see */
 
 Modified: head/lib/libedit/read.c
 ==============================================================================
 --- head/lib/libedit/read.c	Fri Jul  6 15:57:03 2012	(r238172)
 +++ head/lib/libedit/read.c	Fri Jul  6 16:43:56 2012	(r238173)
 @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$");
  #include <stdlib.h>
  #include "el.h"
  
 -#define	OKCMD	-1	/* must be -1! */
 +#define	OKCMD	-1
  
  private int	read__fixio(int, int);
  private int	read_preread(EditLine *);
 @@ -170,7 +170,7 @@ read__fixio(int fd __unused, int e)
  		return (e ? 0 : -1);
  
  	case EINTR:
 -		return (-1);
 +		return (0);
  
  	default:
  		return (-1);
 @@ -235,12 +235,9 @@ read_getcmd(EditLine *el, el_action_t *c
  	el_action_t cmd;
  	int num;
  
 -	el->el_errno = 0;
  	do {
 -		if ((num = el_getc(el, ch)) != 1) {	/* if EOF or error */
 -			el->el_errno = num == 0 ? 0 : errno;
 +		if ((num = el_getc(el, ch)) != 1)	/* if EOF or error */
  			return (num);
 -		}
  
  #ifdef	KANJI
  		if ((*ch & 0200)) {
 @@ -292,21 +289,14 @@ read_char(EditLine *el, char *cp)
  	ssize_t num_read;
  	int tried = 0;
  
 - again:
 -	el->el_signal->sig_no = 0;
 -	while ((num_read = read(el->el_infd, cp, 1)) == -1) {
 -		if (el->el_signal->sig_no == SIGCONT) {
 -			sig_set(el);
 -			el_set(el, EL_REFRESH);
 -			goto again;
 -		}
 +	while ((num_read = read(el->el_infd, cp, 1)) == -1)
  		if (!tried && read__fixio(el->el_infd, errno) == 0)
  			tried = 1;
  		else {
  			*cp = '\0';
  			return (-1);
  		}
 -	}
 +
  	return (int)num_read;
  }
  
 @@ -413,20 +403,17 @@ el_gets(EditLine *el, int *nread)
  	int num;		/* how many chars we have read at NL */
  	char ch;
  	int crlf = 0;
 -	int nrb;
  #ifdef FIONREAD
  	c_macro_t *ma = &el->el_chared.c_macro;
  #endif /* FIONREAD */
  
 -	if (nread == NULL)
 -		nread = &nrb;
  	*nread = 0;
  
  	if (el->el_flags & NO_TTY) {
  		char *cp = el->el_line.buffer;
  		size_t idx;
  
 -		while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
 +		while ((*el->el_read.read_char)(el, cp) == 1) {
  			/* make sure there is space for next character */
  			if (cp + 1 >= el->el_line.limit) {
  				idx = (cp - el->el_line.buffer);
 @@ -440,16 +427,12 @@ el_gets(EditLine *el, int *nread)
  			if (cp[-1] == '\r' || cp[-1] == '\n')
  				break;
  		}
 -		if (num == -1) {
 -			if (errno == EINTR)
 -				cp = el->el_line.buffer;
 -			el->el_errno = errno;
 -		}
  
  		el->el_line.cursor = el->el_line.lastchar = cp;
  		*cp = '\0';
 -		*nread = (int)(el->el_line.cursor - el->el_line.buffer);
 -		goto done;
 +		if (nread)
 +			*nread = (int)(el->el_line.cursor - el->el_line.buffer);
 +		return (*nread ? el->el_line.buffer : NULL);
  	}
  
  
 @@ -460,8 +443,8 @@ el_gets(EditLine *el, int *nread)
  		(void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs);
  		if (chrs == 0) {
  			if (tty_rawmode(el) < 0) {
 -				errno = 0;
 -				*nread = 0;
 +				if (nread)
 +					*nread = 0;
  				return (NULL);
  			}
  		}
 @@ -474,7 +457,6 @@ el_gets(EditLine *el, int *nread)
  	if (el->el_flags & EDIT_DISABLED) {
  		char *cp;
  		size_t idx;
 -
  		if ((el->el_flags & UNBUFFERED) == 0)
  			cp = el->el_line.buffer;
  		else
 @@ -482,7 +464,7 @@ el_gets(EditLine *el, int *nread)
  
  		term__flush(el);
  
 -		while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
 +		while ((*el->el_read.read_char)(el, cp) == 1) {
  			/* make sure there is space next character */
  			if (cp + 1 >= el->el_line.limit) {
  				idx = (cp - el->el_line.buffer);
 @@ -498,15 +480,11 @@ el_gets(EditLine *el, int *nread)
  				break;
  		}
  
 -		if (num == -1) {
 -			if (errno == EINTR)
 -				cp = el->el_line.buffer;
 -			el->el_errno = errno;
 -		}
 -
  		el->el_line.cursor = el->el_line.lastchar = cp;
  		*cp = '\0';
 -		goto done;
 +		if (nread)
 +			*nread = (int)(el->el_line.cursor - el->el_line.buffer);
 +		return (*nread ? el->el_line.buffer : NULL);
  	}
  
  	for (num = OKCMD; num == OKCMD;) {	/* while still editing this
 @@ -522,12 +500,6 @@ el_gets(EditLine *el, int *nread)
  #endif /* DEBUG_READ */
  			break;
  		}
 -		if (el->el_errno == EINTR) {
 -			el->el_line.buffer[0] = '\0';
 -			el->el_line.lastchar =
 -			    el->el_line.cursor = el->el_line.buffer;
 -			break;
 -		}
  		if ((unsigned int)cmdnum >= (unsigned int)el->el_map.nfunc) {	/* BUG CHECK command */
  #ifdef DEBUG_EDIT
  			(void) fprintf(el->el_errfile,
 @@ -645,17 +617,12 @@ el_gets(EditLine *el, int *nread)
  	/* make sure the tty is set up correctly */
  	if ((el->el_flags & UNBUFFERED) == 0) {
  		read_finish(el);
 -		*nread = num != -1 ? num : 0;
 +		if (nread)
 +			*nread = num;
  	} else {
 -		*nread = (int)(el->el_line.lastchar - el->el_line.buffer);
 +		if (nread)
 +			*nread =
 +			    (int)(el->el_line.lastchar - el->el_line.buffer);
  	}
 -done:
 -	if (*nread == 0) {
 -		if (num == -1) {
 -			*nread = -1;
 -			errno = el->el_errno;
 -		}
 -		return NULL;
 -	} else
 -		return el->el_line.buffer;
 +	return (num ? el->el_line.buffer : NULL);
  }
 
 Modified: head/lib/libedit/sig.c
 ==============================================================================
 --- head/lib/libedit/sig.c	Fri Jul  6 15:57:03 2012	(r238172)
 +++ head/lib/libedit/sig.c	Fri Jul  6 16:43:56 2012	(r238173)
 @@ -29,7 +29,7 @@
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   *
 - *	$NetBSD: sig.c,v 1.15 2009/02/19 15:20:22 christos Exp $
 + *	$NetBSD: sig.c,v 1.14 2009/02/18 15:04:40 christos Exp $
   */
  
  #if !defined(lint) && !defined(SCCSID)
 @@ -73,8 +73,6 @@ sig_handler(int signo)
  	(void) sigaddset(&nset, signo);
  	(void) sigprocmask(SIG_BLOCK, &nset, &oset);
  
 -	sel->el_signal->sig_no = signo;
 -
  	switch (signo) {
  	case SIGCONT:
  		tty_rawmode(sel);
 @@ -160,12 +158,12 @@ sig_set(EditLine *el)
  	struct sigaction osa, nsa;
  
  	nsa.sa_handler = sig_handler;
 -	nsa.sa_flags = 0;
  	sigemptyset(&nsa.sa_mask);
  
  	(void) sigprocmask(SIG_BLOCK, &el->el_signal->sig_set, &oset);
  
  	for (i = 0; sighdl[i] != -1; i++) {
 +		nsa.sa_flags = SIGINT ? 0 : SA_RESTART;
  		/* This could happen if we get interrupted */
  		if (sigaction(sighdl[i], &nsa, &osa) != -1 &&
  		    osa.sa_handler != sig_handler)
 
 Modified: head/lib/libedit/sig.h
 ==============================================================================
 --- head/lib/libedit/sig.h	Fri Jul  6 15:57:03 2012	(r238172)
 +++ head/lib/libedit/sig.h	Fri Jul  6 16:43:56 2012	(r238173)
 @@ -30,7 +30,7 @@
   * SUCH DAMAGE.
   *
   *	@(#)sig.h	8.1 (Berkeley) 6/4/93
 - *	$NetBSD: sig.h,v 1.5 2003/08/07 16:44:33 agc Exp $
 + *	$NetBSD: sig.h,v 1.7 2009/02/15 21:25:01 christos Exp $
   * $FreeBSD$
   */
  
 @@ -61,7 +61,6 @@
  typedef struct {
  	struct sigaction sig_action[ALLSIGSNO];
  	sigset_t sig_set;
 -	volatile sig_atomic_t sig_no;
  } *el_signal_t;
  
  protected void	sig_end(EditLine*);
 _______________________________________________
 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"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/169603: commit references a PR
Date: Mon,  9 Jul 2012 09:11:23 +0000 (UTC)

 Author: pfg
 Date: Mon Jul  9 09:11:07 2012
 New Revision: 238286
 URL: http://svn.freebsd.org/changeset/base/238286
 
 Log:
   MFC	r238173:
   
   Fix issue resizing bin/sh
   
   This partially reverts some changes from r237448 that are causing
   breakage when resizing under bin/sh .
   
   Reverted changes from NetBSD are:
   
   Mar 10 20:46:15 2009 - editline.3 read.c
   make el_gets set the count to -1 on error to distinguish between EOF and
   error.
   
   Feb 19 15:20:22 2009 - read.c sig.c sig.h
   reset and redraw on sigcont. From Anon Ymous.
   
   Feb 15 21:24:13 2009
   don't restart on EINTR, instead return NULL immediately. From Anon Ymous
   
   PR:		169603
   Reported by:	Peter Jeremy, David Shao
   MFC after:	3 days
   Approved by:	re
 
 Modified:
   stable/9/lib/libedit/editline.3
   stable/9/lib/libedit/el.h
   stable/9/lib/libedit/read.c
   stable/9/lib/libedit/sig.c
   stable/9/lib/libedit/sig.h
 Directory Properties:
   stable/9/lib/libedit/   (props changed)
 
 Modified: stable/9/lib/libedit/editline.3
 ==============================================================================
 --- stable/9/lib/libedit/editline.3	Mon Jul  9 08:42:54 2012	(r238285)
 +++ stable/9/lib/libedit/editline.3	Mon Jul  9 09:11:07 2012	(r238286)
 @@ -162,11 +162,6 @@ is modified to contain the number of cha
  Returns the line read if successful, or
  .Dv NULL
  if no characters were read or if an error occurred.
 -If an error occurred,
 -.Fa count
 -is set to \-1 and
 -.Dv errno
 -contains the error code that caused it.
  The return value may not remain valid across calls to
  .Fn el_gets
  and must be copied if the data is to be retained.
 
 Modified: stable/9/lib/libedit/el.h
 ==============================================================================
 --- stable/9/lib/libedit/el.h	Mon Jul  9 08:42:54 2012	(r238285)
 +++ stable/9/lib/libedit/el.h	Mon Jul  9 09:11:07 2012	(r238286)
 @@ -115,7 +115,6 @@ struct editline {
  	FILE		 *el_errfile;	/* Stdio stuff			*/
  	int		  el_infd;	/* Input file descriptor	*/
  	int		  el_flags;	/* Various flags.		*/
 -	int		  el_errno;	/* Local copy of errno		*/
  	coord_t		  el_cursor;	/* Cursor location		*/
  	char		**el_display;	/* Real screen image = what is there */
  	char		**el_vdisplay;	/* Virtual screen image = what we see */
 
 Modified: stable/9/lib/libedit/read.c
 ==============================================================================
 --- stable/9/lib/libedit/read.c	Mon Jul  9 08:42:54 2012	(r238285)
 +++ stable/9/lib/libedit/read.c	Mon Jul  9 09:11:07 2012	(r238286)
 @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$");
  #include <stdlib.h>
  #include "el.h"
  
 -#define	OKCMD	-1	/* must be -1! */
 +#define	OKCMD	-1
  
  private int	read__fixio(int, int);
  private int	read_preread(EditLine *);
 @@ -170,7 +170,7 @@ read__fixio(int fd __unused, int e)
  		return (e ? 0 : -1);
  
  	case EINTR:
 -		return (-1);
 +		return (0);
  
  	default:
  		return (-1);
 @@ -235,12 +235,9 @@ read_getcmd(EditLine *el, el_action_t *c
  	el_action_t cmd;
  	int num;
  
 -	el->el_errno = 0;
  	do {
 -		if ((num = el_getc(el, ch)) != 1) {	/* if EOF or error */
 -			el->el_errno = num == 0 ? 0 : errno;
 +		if ((num = el_getc(el, ch)) != 1)	/* if EOF or error */
  			return (num);
 -		}
  
  #ifdef	KANJI
  		if ((*ch & 0200)) {
 @@ -292,21 +289,14 @@ read_char(EditLine *el, char *cp)
  	ssize_t num_read;
  	int tried = 0;
  
 - again:
 -	el->el_signal->sig_no = 0;
 -	while ((num_read = read(el->el_infd, cp, 1)) == -1) {
 -		if (el->el_signal->sig_no == SIGCONT) {
 -			sig_set(el);
 -			el_set(el, EL_REFRESH);
 -			goto again;
 -		}
 +	while ((num_read = read(el->el_infd, cp, 1)) == -1)
  		if (!tried && read__fixio(el->el_infd, errno) == 0)
  			tried = 1;
  		else {
  			*cp = '\0';
  			return (-1);
  		}
 -	}
 +
  	return (int)num_read;
  }
  
 @@ -413,20 +403,17 @@ el_gets(EditLine *el, int *nread)
  	int num;		/* how many chars we have read at NL */
  	char ch;
  	int crlf = 0;
 -	int nrb;
  #ifdef FIONREAD
  	c_macro_t *ma = &el->el_chared.c_macro;
  #endif /* FIONREAD */
  
 -	if (nread == NULL)
 -		nread = &nrb;
  	*nread = 0;
  
  	if (el->el_flags & NO_TTY) {
  		char *cp = el->el_line.buffer;
  		size_t idx;
  
 -		while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
 +		while ((*el->el_read.read_char)(el, cp) == 1) {
  			/* make sure there is space for next character */
  			if (cp + 1 >= el->el_line.limit) {
  				idx = (cp - el->el_line.buffer);
 @@ -440,16 +427,12 @@ el_gets(EditLine *el, int *nread)
  			if (cp[-1] == '\r' || cp[-1] == '\n')
  				break;
  		}
 -		if (num == -1) {
 -			if (errno == EINTR)
 -				cp = el->el_line.buffer;
 -			el->el_errno = errno;
 -		}
  
  		el->el_line.cursor = el->el_line.lastchar = cp;
  		*cp = '\0';
 -		*nread = (int)(el->el_line.cursor - el->el_line.buffer);
 -		goto done;
 +		if (nread)
 +			*nread = (int)(el->el_line.cursor - el->el_line.buffer);
 +		return (*nread ? el->el_line.buffer : NULL);
  	}
  
  
 @@ -460,8 +443,8 @@ el_gets(EditLine *el, int *nread)
  		(void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs);
  		if (chrs == 0) {
  			if (tty_rawmode(el) < 0) {
 -				errno = 0;
 -				*nread = 0;
 +				if (nread)
 +					*nread = 0;
  				return (NULL);
  			}
  		}
 @@ -474,7 +457,6 @@ el_gets(EditLine *el, int *nread)
  	if (el->el_flags & EDIT_DISABLED) {
  		char *cp;
  		size_t idx;
 -
  		if ((el->el_flags & UNBUFFERED) == 0)
  			cp = el->el_line.buffer;
  		else
 @@ -482,7 +464,7 @@ el_gets(EditLine *el, int *nread)
  
  		term__flush(el);
  
 -		while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
 +		while ((*el->el_read.read_char)(el, cp) == 1) {
  			/* make sure there is space next character */
  			if (cp + 1 >= el->el_line.limit) {
  				idx = (cp - el->el_line.buffer);
 @@ -498,15 +480,11 @@ el_gets(EditLine *el, int *nread)
  				break;
  		}
  
 -		if (num == -1) {
 -			if (errno == EINTR)
 -				cp = el->el_line.buffer;
 -			el->el_errno = errno;
 -		}
 -
  		el->el_line.cursor = el->el_line.lastchar = cp;
  		*cp = '\0';
 -		goto done;
 +		if (nread)
 +			*nread = (int)(el->el_line.cursor - el->el_line.buffer);
 +		return (*nread ? el->el_line.buffer : NULL);
  	}
  
  	for (num = OKCMD; num == OKCMD;) {	/* while still editing this
 @@ -522,12 +500,6 @@ el_gets(EditLine *el, int *nread)
  #endif /* DEBUG_READ */
  			break;
  		}
 -		if (el->el_errno == EINTR) {
 -			el->el_line.buffer[0] = '\0';
 -			el->el_line.lastchar =
 -			    el->el_line.cursor = el->el_line.buffer;
 -			break;
 -		}
  		if ((unsigned int)cmdnum >= (unsigned int)el->el_map.nfunc) {	/* BUG CHECK command */
  #ifdef DEBUG_EDIT
  			(void) fprintf(el->el_errfile,
 @@ -645,17 +617,12 @@ el_gets(EditLine *el, int *nread)
  	/* make sure the tty is set up correctly */
  	if ((el->el_flags & UNBUFFERED) == 0) {
  		read_finish(el);
 -		*nread = num != -1 ? num : 0;
 +		if (nread)
 +			*nread = num;
  	} else {
 -		*nread = (int)(el->el_line.lastchar - el->el_line.buffer);
 +		if (nread)
 +			*nread =
 +			    (int)(el->el_line.lastchar - el->el_line.buffer);
  	}
 -done:
 -	if (*nread == 0) {
 -		if (num == -1) {
 -			*nread = -1;
 -			errno = el->el_errno;
 -		}
 -		return NULL;
 -	} else
 -		return el->el_line.buffer;
 +	return (num ? el->el_line.buffer : NULL);
  }
 
 Modified: stable/9/lib/libedit/sig.c
 ==============================================================================
 --- stable/9/lib/libedit/sig.c	Mon Jul  9 08:42:54 2012	(r238285)
 +++ stable/9/lib/libedit/sig.c	Mon Jul  9 09:11:07 2012	(r238286)
 @@ -29,7 +29,7 @@
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   *
 - *	$NetBSD: sig.c,v 1.15 2009/02/19 15:20:22 christos Exp $
 + *	$NetBSD: sig.c,v 1.14 2009/02/18 15:04:40 christos Exp $
   */
  
  #if !defined(lint) && !defined(SCCSID)
 @@ -73,8 +73,6 @@ sig_handler(int signo)
  	(void) sigaddset(&nset, signo);
  	(void) sigprocmask(SIG_BLOCK, &nset, &oset);
  
 -	sel->el_signal->sig_no = signo;
 -
  	switch (signo) {
  	case SIGCONT:
  		tty_rawmode(sel);
 @@ -160,12 +158,12 @@ sig_set(EditLine *el)
  	struct sigaction osa, nsa;
  
  	nsa.sa_handler = sig_handler;
 -	nsa.sa_flags = 0;
  	sigemptyset(&nsa.sa_mask);
  
  	(void) sigprocmask(SIG_BLOCK, &el->el_signal->sig_set, &oset);
  
  	for (i = 0; sighdl[i] != -1; i++) {
 +		nsa.sa_flags = SIGINT ? 0 : SA_RESTART;
  		/* This could happen if we get interrupted */
  		if (sigaction(sighdl[i], &nsa, &osa) != -1 &&
  		    osa.sa_handler != sig_handler)
 
 Modified: stable/9/lib/libedit/sig.h
 ==============================================================================
 --- stable/9/lib/libedit/sig.h	Mon Jul  9 08:42:54 2012	(r238285)
 +++ stable/9/lib/libedit/sig.h	Mon Jul  9 09:11:07 2012	(r238286)
 @@ -30,7 +30,7 @@
   * SUCH DAMAGE.
   *
   *	@(#)sig.h	8.1 (Berkeley) 6/4/93
 - *	$NetBSD: sig.h,v 1.5 2003/08/07 16:44:33 agc Exp $
 + *	$NetBSD: sig.h,v 1.7 2009/02/15 21:25:01 christos Exp $
   * $FreeBSD$
   */
  
 @@ -61,7 +61,6 @@
  typedef struct {
  	struct sigaction sig_action[ALLSIGSNO];
  	sigset_t sig_set;
 -	volatile sig_atomic_t sig_no;
  } *el_signal_t;
  
  protected void	sig_end(EditLine*);
 _______________________________________________
 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"
 
State-Changed-From-To: open->closed 
State-Changed-By: pfg 
State-Changed-When: Mon Jul 9 16:33:31 UTC 2012 
State-Changed-Why:  
libedit was partially reverted in 9-stable and 8-stable. 
A better fix will be provided for -current. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=169603 
>Unformatted:
