[Bug 239604] FIONREAD ioctl returns the wrong result on a master pty after the slave has been closed

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri Aug 2 15:51:18 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239604

            Bug ID: 239604
           Summary: FIONREAD ioctl returns the wrong result on a master
                    pty after the slave has been closed
           Product: Base System
           Version: 11.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs at FreeBSD.org
          Reporter: martin at lispworks.com
 Attachment #206224 text/plain
         mime type:

Created attachment 206224
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=206224&action=edit
Example to reproduce the bug

Compile the attached example with:

cc -lutil pty-fionread.c

When it is run, I would expect it to print:

bytes1 = 0
bytes2 = 0

but in FreeBSD it prints:

bytes1 = 0
bytes2 = 1

It looks like the FIOREAD ioctl always returns 1 after the slave side of the
pty has been closed, regardless of whether any data is available.  This
contradicts the man page and also differs from Linux (and Solaris and AIX,
which have very different code to open the pty).

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


More information about the freebsd-bugs mailing list