From tim@robbins.dropbear.id.au  Mon Apr  7 07:14:20 2003
Return-Path: <tim@robbins.dropbear.id.au>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1C3E937B401
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  7 Apr 2003 07:14:20 -0700 (PDT)
Received: from smtp02.syd.iprimus.net.au (smtp02.syd.iprimus.net.au [210.50.76.52])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 953C243F75
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  7 Apr 2003 07:14:19 -0700 (PDT)
	(envelope-from tim@robbins.dropbear.id.au)
Received: from dilbert.robbins.dropbear.id.au (210.50.44.252) by smtp02.syd.iprimus.net.au (7.0.012)
        id 3E8A16000013695F for FreeBSD-gnats-submit@freebsd.org; Tue, 8 Apr 2003 00:14:18 +1000
Received: by dilbert.robbins.dropbear.id.au (Postfix, from userid 1000)
	id 3A994C90D; Tue,  8 Apr 2003 00:14:22 +1000 (EST)
Message-Id: <20030407141422.3A994C90D@dilbert.robbins.dropbear.id.au>
Date: Tue,  8 Apr 2003 00:14:22 +1000 (EST)
From: Tim Robbins <tim@robbins.dropbear.id.au>
Reply-To: Tim Robbins <tim@robbins.dropbear.id.au>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: vi invoked from chpass and vipw exits on ^C
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         50679
>Category:       bin
>Synopsis:       vi invoked from chpass and vipw exits on ^C
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 07 07:20:12 PDT 2003
>Closed-Date:    Wed Apr 09 09:41:04 PDT 2003
>Last-Modified:  Wed Apr 09 09:41:04 PDT 2003
>Originator:     Tim Robbins
>Release:        FreeBSD 5.0-CURRENT, 8 April 2003
>Organization:
The FreeBSD Project
>Environment:
System: FreeBSD 5.0-CURRENT, 8 April 2003

Problem also occurs on a system from March 30 ie. before Jeff's thread signal
mask code was committed.

>Description:
If you run chpass or vipw and press ^C in vi, vi exits immediately and says:
	Error: input: Input/output error
instead of writing
Interrupted
	and continuing.

This is a regression over 4.x (specifically 4.8).

It may be necessary to press ^C more than once to trigger the bug sometimes
(esp. for vipw).

>How-To-Repeat:
See above.
>Fix:
Not known. Suspect signal handling bug in libutil. Needing to press ^C twice
to get vipw's vi invocation to die makes me think of SA_RESETHAND.
>Release-Note:
>Audit-Trail:

From: Tim Robbins <tjr@FreeBSD.ORG>
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Cc:  
Subject: Re: bin/50679: vi invoked from chpass and vipw exits on ^C
Date: Tue, 8 Apr 2003 00:35:31 +1000

 Possible patch:
 
 Index: pw_util.c
 ===================================================================
 RCS file: /home/ncvs/src/lib/libutil/pw_util.c,v
 retrieving revision 1.28
 diff -U10 -p -r1.28 pw_util.c
 --- pw_util.c	17 Mar 2003 02:12:55 -0000	1.28
 +++ pw_util.c	7 Apr 2003 13:41:01 -0000
 @@ -315,20 +315,22 @@ pw_edit(int notsetuid)
  			_exit(EXIT_FAILURE);
  		}
  		errno = 0;
  		execl(_PATH_BSHELL, "sh", "-c", editcmd, NULL);
  		free(editcmd);
  		_exit(errno);
  	default:
  		/* parent */
  		break;
  	}
 +	setpgid(editpid, editpid);
 +	tcsetpgrp(1, editpid);
  	for (;;) {
  		editpid = waitpid(editpid, &pstat, WUNTRACED);
  		if (editpid == -1) {
  			unlink(tempname);
  			return (-1);
  		} else if (WIFSTOPPED(pstat)) {
  			raise(WSTOPSIG(pstat));
  		} else if (WIFEXITED(pstat) && WEXITSTATUS(pstat) == 0) {
  			editpid = -1;
  			break;
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: tjr 
Responsible-Changed-When: Tue Apr 8 02:55:52 PDT 2003 
Responsible-Changed-Why:  
I think src/lib/libutil/pw_util.c rev. 1.24 causes this incorrect behaviour - 
either interrupt/quit/etc. signals should be ignored while the editor is 
running, or the editor should be started in its own process group. Ignoring 
signals is what 4.x do; the patch attached to this PR runs the editor in its 
own process group, and has not been tested very well. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=50679 
State-Changed-From-To: open->suspended 
State-Changed-By: des 
State-Changed-When: Tue Apr 8 11:05:25 PDT 2003 
State-Changed-Why:  
A workaround has been committed, but I do not know the correct solution yet. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=50679 
State-Changed-From-To: suspended->closed 
State-Changed-By: des 
State-Changed-When: Wed Apr 9 09:41:02 PDT 2003 
State-Changed-Why:  
Fixed, thanks. 

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