[Bug 246350] kqueue fails to report pipe writable after the read end is closed
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Sun May 10 07:22:41 UTC 2020
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246350
Bug ID: 246350
Summary: kqueue fails to report pipe writable after the read
end is closed
Product: Base System
Version: 12.1-RELEASE
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: kern
Assignee: bugs at FreeBSD.org
Reporter: njs at pobox.com
Attachment #214335 text/plain
mime type:
Created attachment 214335
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=214335&action=edit
fbsd-kqueue-pipe-bug-demo.py
Consider the following sequence of events:
1. Call pipe() to open a pipe
2. Set the write side to non-blocking
3. Write into the write side until the pipe buffer is full and write() returns
EWOULDBLOCK
4. Use kqueue to register a wait for the write end to become writable again
(EVFILT_WRITE)
5. Close the read end of the pipe
At this point, I would expect that kqueue would return an event to report that
the pipe is "writable". The man page says it will ("The filter will set EV_EOF
when the reader disconnects"). On the same pipe, in this situation, select()
reports that it's writable. On macOS, kqueue reports that it's writable.
However, on FreeBSD 12, kqueue does *not* report any event in this situation.
I've attached a minimal Python script to demonstrate.
Output from the script when running on macOS:
------------
filling pipe buffer
select() says the write pipe is NOT writable
closing read end of pipe
select() says the write pipe is writable
waiting for kqueue to report the write end is writable
done!
[<select.kevent ident=4 filter=-2 flags=0x8001 fflags=0x0 data=0x0 udata=0x0>]
------------
Output from the script when running on FreeBSD 12.1-RELEASE:
------------
filling pipe buffer
select() says the write pipe is NOT writable
closing read end of pipe
select() says the write pipe is writable
waiting for kqueue to report the write end is writable
[...hangs forever...]
------------
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list