From robert@sleipnir.watson.org  Sat Oct 24 19:58:37 1998
Received: from sleipnir.watson.org (n234-113.mtholyoke.edu [138.110.234.113])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA29393
          for <FreeBSD-gnats-submit@freebsd.org>; Sat, 24 Oct 1998 19:58:36 -0700 (PDT)
          (envelope-from robert@sleipnir.watson.org)
Received: (from robert@localhost)
	by sleipnir.watson.org (8.9.1/8.9.1) id HAA15863;
	Sat, 24 Oct 1998 07:43:18 -0400 (EDT)
	(envelope-from robert)
Message-Id: <199810241143.HAA15863@sleipnir.watson.org>
Date: Sat, 24 Oct 1998 07:43:18 -0400 (EDT)
From: robert@fledge.watson.org
Reply-To: robert+freebsd@cyrus.watson.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: ex/vi: Error: tcsetattr: Interrupted system call
X-Send-Pr-Version: 3.2

>Number:         8438
>Category:       bin
>Synopsis:       ex/vi: Error: tcsetattr: Interrupted system call
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    rwatson
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 24 20:00:00 PDT 1998
>Closed-Date:    Thu Nov 8 18:24:28 PST 2001
>Last-Modified:  Thu Nov 08 18:25:57 PST 2001
>Originator:     Robert Watson
>Release:        FreeBSD 3.0-BETA i386
>Organization:
>Environment:

3.0-BETA/RELEASE, using vi against a file in the local FFS file system
/usr.  X-windows using xterm, XiG's X server for notebooks.

>Description:

When resizing an xterm and using vi, once in a while I get:

ex/vi: Error: tcsetattr: Interrupted system call

This kills vi.  This is not good.  I believe I have observed this both
in command and edit modes.

>How-To-Repeat:

Start editing a file.  Now resize your xterm.  This does not always
appear to happen -- in fact, only infrequently.  I'm not sure if there
is a correspondence to the size of the file being edited.  I am unable
to repeat this consistently, but it has happened at least a few times 
in the past few months.

>Fix:
	
I'm on the road, so can't check the source or see if there is already
a PR in for this.  However, I'd guess that something in curses/ncurses/
whatever vi uses doesn't wrap a syscall in a check for EINTR, and this
results in vi terminating from an error it does not expect.

>Release-Note:
>Audit-Trail:

From: Matthias Buelow <mkb@altair.mayn.de>
To: robert+freebsd@cyrus.watson.org
Cc: freebsd-bugs@freebsd.org
Subject: [patch] Re: bin/8438: ex/vi: Error: tcsetattr: Interrupted system call 
Date: Sat, 24 Oct 1998 20:58:43 PDT

 "robert@fledge.watson.org" wrote:
 
 >>Number:         8438
 >>Category:       bin
 >>Synopsis:       ex/vi: Error: tcsetattr: Interrupted system call
 
 >3.0-BETA/RELEASE, using vi against a file in the local FFS file system
 >/usr.  X-windows using xterm, XiG's X server for notebooks.
 >
 >>Description:
 >
 >When resizing an xterm and using vi, once in a while I get:
 >
 >ex/vi: Error: tcsetattr: Interrupted system call
 >
 >This kills vi.  This is not good.  I believe I have observed this both
 >in command and edit modes.
 >
 >>How-To-Repeat:
 >
 >Start editing a file.  Now resize your xterm.  This does not always
 >appear to happen -- in fact, only infrequently.  I'm not sure if there
 >is a correspondence to the size of the file being edited.  I am unable
 >to repeat this consistently, but it has happened at least a few times 
 >in the past few months.
 >
 >>Fix:
 >	
 >I'm on the road, so can't check the source or see if there is already
 >a PR in for this.  However, I'd guess that something in curses/ncurses/
 >whatever vi uses doesn't wrap a syscall in a check for EINTR, and this
 >results in vi terminating from an error it does not expect.
 
 Yes, there're two occurrances of tcsetattr that are checked for errors,
 but EINTR is not taken care of.  It is quite trivial to do this.
 Keith Bostic (the author of nvi) is busy with db 2.x since 1996 (and
 doesn't seem to have time for fixing bugs), so you could try the following
 patch from a mere user (me :).  Please let me know if the problem goes
 away.  You could also try to get the source for 1.79 and build with the
 internal curses subset, instead of linking against FreeBSD libcurses
 (it is linked against the system's curses at least in 2.2.6 and 2.2.7;
 this is probably not the best idea, since the bundled curses is supposed
 to work best with it).
 
 
 --- cl/cl_screen.c.orig-1.79	Sun Oct 25 04:49:59 1998
 +++ cl/cl_screen.c	Sun Oct 25 04:50:54 1998
 @@ -368,6 +368,8 @@
  
  fast:	/* Set the terminal modes. */
  	if (tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &clp->vi_enter)) {
 +		if (EINTR == errno)
 +			goto fast;
  		msgq(sp, M_SYSERR, "tcsetattr");
  err:		(void)cl_vi_end(sp->gp);
  		return (1);
 @@ -486,6 +488,8 @@
  #endif
  
  fast:	if (tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->ex_enter)) {
 +		if (EINTR == errno)
 +			goto fast;
  		msgq(sp, M_SYSERR, "tcsetattr");
  		return (1);
  	}
 
  - mkb
 
 To Unsubscribe: send mail to majordomo@FreeBSD.org
 with "unsubscribe freebsd-bugs" in the body of the message
State-Changed-From-To: open->closed 
State-Changed-By: rwatson 
State-Changed-When: Thu Nov 8 18:24:28 PST 2001 
State-Changed-Why:  
Fix committed, three years later. 




Responsible-Changed-From-To: freebsd-bugs->rwatson 
Responsible-Changed-By: rwatson 
Responsible-Changed-When: Thu Nov 8 18:24:28 PST 2001 
Responsible-Changed-Why:  
Because I committed the fix. 
Oh, and it was my PR in the first place. 

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