From owner-freebsd-bugs@freebsd.org Sun Aug 2 23:20:03 2020 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 46A683AA2AC for ; Sun, 2 Aug 2020 23:20:03 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4BKcS31CYMz44Dm for ; Sun, 2 Aug 2020 23:20:03 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 298F23AA59C; Sun, 2 Aug 2020 23:20:03 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 295663AA59B for ; Sun, 2 Aug 2020 23:20:03 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BKcS30JtTz44Dl for ; Sun, 2 Aug 2020 23:20:03 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E2826B064 for ; Sun, 2 Aug 2020 23:20:02 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 072NK29w028217 for ; Sun, 2 Aug 2020 23:20:02 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 072NK2tt028212 for bugs@FreeBSD.org; Sun, 2 Aug 2020 23:20:02 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 248440] kevent not returning full pipes registered with EVFILT_WRITE when on read end closure Date: Sun, 02 Aug 2020 23:20:02 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 12.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: larkinconr@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.mimetype attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2020 23:20:03 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D248440 Bug ID: 248440 Summary: kevent not returning full pipes registered with EVFILT_WRITE when on read end closure 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: larkinconr@gmail.com Attachment #216970 text/plain mime type: Created attachment 216970 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D216970&action= =3Dedit test program to reproduce bug via filling/monitoring stdout When using kevent to monitor the write end of a pipe for writability via EVFILT_WRITE, if the pipe is full when the read end is closed, an event is = not returned. I would expect an event with EV_EOF set to be returned. Note that this does not seem to reproduce with sockets or named pipes (fifos), those return an event with EV_EOF set just fine in this situation. I'm attaching a sample program that verifies stdout is a pipe and then atte= mpts to fill it with data, then waits for an event with EVFILT_WRITE for stdout= . If you pipe this to some program that doesn't read stdin, for instance sleep(= 1), the pipeline hangs forever. Notably, if you instead redirect its output to a named pipe and have sleep "read" the named pipe with shell redirection, the program *does* receive an event for stdout with EV_EOF set once sleep exits. I originally detected this with a test case that creates a pipe via pipe(2)= in process, so testing with socketpair(2) was convenient, but it used threads = and other infrastructure etc so I wrote a new test program. But I just want to mention that because it would seem to exclude some weird interaction with my shell etc. Example test case using the attached kqwrite.c: $ ./kqwrite | /bin/sleep 1 # hangs forever ^C $ mkfifo dummy; /bin/sleep 1 < dummy &; ./kqwrite > dummy # returns EV_EOF: [1] 1734 kevent returned 1 1 -2 32768 0 0 0x0 [1] + done /bin/sleep 1 < dummy --=20 You are receiving this mail because: You are the assignee for the bug.=