Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 May 2020 07:22:40 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 246350] kqueue fails to report pipe writable after the read end is closed
Message-ID:  <bug-246350-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D246350

            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@FreeBSD.org
          Reporter: njs@pobox.com
 Attachment #214335 text/plain
         mime type:

Created attachment 214335
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D214335&action=
=3Dedit
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() retu=
rns
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 t=
hat
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 situatio=
n.

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=3D4 filter=3D-2 flags=3D0x8001 fflags=3D0x0 data=3D0x=
0 udata=3D0x0>]
------------

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...]
------------

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-246350-227>