bin/21089: vi silently corrupt open file on SIGINT when entering :wq in command mode

Jaakko Heinonen jh at saunalahti.fi
Wed Feb 6 07:00:10 UTC 2008


The following reply was made to PR bin/21089; it has been noted by GNATS.

From: Jaakko Heinonen <jh at saunalahti.fi>
To: bug-followup at FreeBSD.org, lfrigault at teaser.fr
Cc: lists at MHoerich.de
Subject: Re: bin/21089: vi silently corrupt open file on SIGINT when
	entering :wq in command mode
Date: Wed, 6 Feb 2008 08:55:06 +0200

 --qDbXVdCdHGoSgWSk
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 
 The bug still exists in 7.0-RC1. I believe that the attached patch fixes
 it. Can you confirm?
 
 -- 
 Jaakko
 
 --qDbXVdCdHGoSgWSk
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="nvi-SIGINT.diff"
 
 Index: ex/ex_quit.c
 ===================================================================
 RCS file: /home/ncvs/src/contrib/nvi/ex/ex_quit.c,v
 retrieving revision 1.1.1.1
 diff -u -r1.1.1.1 ex_quit.c
 --- ex/ex_quit.c	1 Nov 1996 06:45:30 -0000	1.1.1.1
 +++ ex/ex_quit.c	6 Feb 2008 06:45:32 -0000
 @@ -35,6 +35,9 @@
  {
  	int force;
  
 +	if (INTERRUPTED(sp))
 +		return (1);
 +
  	force = FL_ISSET(cmdp->iflags, E_C_FORCE);
  
  	/* Check for file modifications, or more files to edit. */
 Index: ex/ex_write.c
 ===================================================================
 RCS file: /home/ncvs/src/contrib/nvi/ex/ex_write.c,v
 retrieving revision 1.1.1.1
 diff -u -r1.1.1.1 ex_write.c
 --- ex/ex_write.c	1 Nov 1996 06:45:31 -0000	1.1.1.1
 +++ ex/ex_write.c	6 Feb 2008 06:45:32 -0000
 @@ -140,6 +140,9 @@
  	int flags;
  	char *name, *p;
  
 +	if (INTERRUPTED(sp))
 +		return (1);
 +
  	NEEDFILE(sp, cmdp);
  
  	/* All write commands can have an associated '!'. */
 @@ -323,8 +326,6 @@
  		for (; fline <= tline; ++fline, ++lcnt) {
  			/* Caller has to provide any interrupt message. */
  			if ((lcnt + 1) % INTERRUPT_CHECK == 0) {
 -				if (INTERRUPTED(sp))
 -					break;
  				if (!silent) {
  					gp->scr_busy(sp, msg, msg == NULL ?
  					    BUSY_UPDATE : BUSY_ON);
 
 --qDbXVdCdHGoSgWSk--


More information about the freebsd-bugs mailing list