Bug 29686

Summary: kevent EV_ADD EVFILT_WRITE does the wrong thing on a closed fd
Product: Base System Reporter: stripes <stripes>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: stripes
Priority: Normal    
Version: 4.3-RELEASE   
Hardware: Any   
OS: Any   

Description stripes 2001-08-14 00:10:01 UTC
	I have a one shot EVFILT_WRITE filter on fd#7, it fires, and I close 
	fd#7.  My code (incorrectly) asks for the filter to be added again  
	without opening the file descriptor again (fd#7 is a TCP stream, when
	open).  kevent does not return with EBADF as I think it should.  This
	might be a documentation issue, maybe someone really does want to
	be told about events on fd#7 after they open it.  I would rather the
	EBADF though.

	kevent does return telling me I can write some data down the CLOSED
	fd#7.  That's just wrong.

	Since we are trying to promote kevent as the new bestest way to do
	event driven I/O and stuff, having it be harder to use then needed
	seems like a bad idea.  That's why I said the bug is "serious" even
	though the work around is "don't write the user land code to do The
	Wrong Thing".

Fix: 

None, but as a work around, be careful not to ask for events on closed
	files.  I admit I did the wrong thing there, but it will be easier to
	spot that if the kernel tells you right away...
How-To-Repeat: 	I can't submit the code, it was done for work.  This pr isn't even from
	the same machine (I did put the problem machine's info in, not my own
	machine's info).
Comment 1 Kris Kennaway freebsd_committer freebsd_triage 2002-01-06 04:09:16 UTC
Responsible Changed
From-To: freebsd-bugs->jlemon

jlemon wrote kq
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2004-09-13 06:59:17 UTC
Responsible Changed
From-To: jlemon->freebsd-bugs

With bugmeister hat on, reassign from recently inactive committer.
Comment 3 Craig Rodrigues freebsd_committer freebsd_triage 2006-06-05 00:37:43 UTC
State Changed
From-To: open->feedback

Can you submit a small code testcase which illustrates the problem? 
It's hard to look at this otherwise.
Comment 4 Remko Lodder freebsd_committer freebsd_triage 2006-11-12 10:31:43 UTC
State Changed
From-To: feedback->closed

Feedback had not been recieved, please submit feedback so that we can 
continue to look into this problem. Till that time i will be closing the 
PR