Bug 24654

Summary: /usr/bin/w doesn't close all files
Product: Base System Reporter: Daniel.Hemmerich <Daniel.Hemmerich>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Daniel.Hemmerich 2001-01-26 05:10:02 UTC
	/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().

Fix: 

Insert prior to line 417 in src/usr.bin/w/w.c the line:
		kvm_close(kd);
How-To-Repeat: 
	You can witness this by stepping through the program via a gdb.
Comment 1 Seth Kingsley 2001-03-15 00:00:39 UTC
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 ||
Comment 2 Poul-Henning Kamp freebsd_committer freebsd_triage 2001-05-28 22:30:35 UTC
State Changed
From-To: open->closed

Committed, thanks!  (although you missed 50% of the relevant exits :-)