From dan@blackhole.gurubox.com  Thu Jan 25 21:07:53 2001
Return-Path: <dan@blackhole.gurubox.com>
Received: from blackhole.gurubox.com (d83b3758.dsl.flashcom.net [216.59.55.88])
	by hub.freebsd.org (Postfix) with ESMTP id 1C75A37B400
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 25 Jan 2001 21:07:53 -0800 (PST)
Received: (from root@localhost)
	by blackhole.gurubox.com (8.11.1/8.9.3) id f0Q57F846613;
	Fri, 26 Jan 2001 00:07:15 -0500 (EST)
	(envelope-from dan)
Message-Id: <200101260507.f0Q57F846613@blackhole.gurubox.com>
Date: Fri, 26 Jan 2001 00:07:15 -0500 (EST)
From: Daniel.Hemmerich@blackhole.gurubox.com
Reply-To: zartik@yahoo.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: /usr/bin/w doesn't close all files
X-Send-Pr-Version: 3.2

>Number:         24654
>Category:       bin
>Synopsis:       /usr/bin/w doesn't close all files
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 25 21:10:02 PST 2001
>Closed-Date:    Mon May 28 14:30:35 PDT 2001
>Last-Modified:  Mon May 28 14:31:00 PDT 2001
>Originator:     Daniel Hemmerich
>Release:        I would presume all versions of FreeBSD, but have not verified that
>Organization:
BSDpro.com
>Environment:

	N/A

>Description:

	/usr/bin/w does not close all files prior to exiting. It calls functions from the kvm 
	library, which in turn is openning /dev/null (at w's request), however, w does not
	call the kvm_close().

>How-To-Repeat:

	You can witness this by stepping through the program via a gdb.

>Fix:

	Insert prior to line 417 in src/usr.bin/w/w.c the line:
		kvm_close(kd);


>Release-Note:
>Audit-Trail:

From: Seth Kingsley <sethk@osd.bsdi.com>
To: freebsd-gnats-submit@FreeBSD.org, zartik@yahoo.com
Cc:  
Subject: Re: bin/24654: /usr/bin/w doesn't close all files
Date: Wed, 14 Mar 2001 16:00:39 -0800

 While all kvm_close() does currently is close() descriptors and free
 dynamic memory, it does seem like the right thing to always call it.
 
 Index: w.c
 ===================================================================
 RCS file: /ncvs/src/usr.bin/w/w.c,v
 retrieving revision 1.38
 diff -u -r1.38 w.c
 --- w.c	1999/11/17 15:28:45	1.38
 +++ w.c	2001/03/14 22:26:06
 @@ -407,6 +407,7 @@
  		longidle = pr_idle(ep->idle);
  		(void)printf("%.*s\n", argwidth - longidle, ep->args);
  	}
 +	(void)kvm_close(kd);
  	exit(0);
  }
  
 -- 
 || Seth Kingsley || BSDi/Open Source Division || sethk@osd.bsdi.com ||
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Mon May 28 14:30:35 PDT 2001 
State-Changed-Why:  
Committed, thanks!  (although you missed 50% of the relevant exits :-) 

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