From nobody Mon Sep 06 10:50:30 2021 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5266117A248F for ; Mon, 6 Sep 2021 10:50:30 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H34tZ1k1rz3NKZ for ; Mon, 6 Sep 2021 10:50:30 +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 1B76C1D65F for ; Mon, 6 Sep 2021 10:50:30 +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 186AoUxT080495 for ; Mon, 6 Sep 2021 10:50:30 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 186AoUMl080494 for bugs@FreeBSD.org; Mon, 6 Sep 2021 10:50:30 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 258310] kevent() does not see signal with zero timeout Date: Mon, 06 Sep 2021 10:50:30 +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: 13.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: arichardson@FreeBSD.org 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 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 List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D258310 Bug ID: 258310 Summary: kevent() does not see signal with zero timeout Product: Base System Version: 13.0-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: arichardson@FreeBSD.org While adding patches to natively support FreeBSD in wayland, I noticed that epoll-shim (used to emulate epoll with kqueue) didn't report signals sent to self via kill() unless I added a non-zero timeout (even in a single-threaded test program). In https://github.com/jiixyj/epoll-shim/pull/32=20 Jan Kokem=C3=BCller provided a reduced test case using only kqueue and keve= nt: ``` #ifdef NDEBUG #undef NDEBUG #endif #define _GNU_SOURCE #include #include #include #include #include #include #include #include int main(void) { int rv; sigset_t set; rv =3D sigemptyset(&set); assert(rv =3D=3D 0); rv =3D sigaddset(&set, SIGUSR1); assert(rv =3D=3D 0); rv =3D sigprocmask(SIG_BLOCK, &set, NULL); assert(rv =3D=3D 0); int skq =3D kqueue(); assert(skq >=3D 0); struct kevent kev; EV_SET(&kev, SIGUSR1, EVFILT_SIGNAL, EV_ADD, 0, 0, 0); rv =3D kevent(skq, &kev, 1, NULL, 0, NULL); assert(rv =3D=3D 0); int kq =3D kqueue(); assert(kq >=3D 0); EV_SET(&kev, skq, EVFILT_READ, EV_ADD | EV_CLEAR, 0, 0, 0); rv =3D kevent(kq, &kev, 1, NULL, 0, NULL); assert(rv =3D=3D 0); for (;;) { rv =3D kill(getpid(), SIGUSR1); assert(rv =3D=3D 0); /* Turn this into `#if 1` to avoid the race. */ #if 0 rv =3D kevent(kq, NULL, 0, &kev, 1, NULL); #else rv =3D kevent(kq, NULL, 0, &kev, 1, &(struct timespec) { 0,= 0 }); #endif assert(rv =3D=3D 1); rv =3D kevent(kq, NULL, 0, &kev, 1, &(struct timespec) { 0,= 0 }); assert(rv =3D=3D 0); rv =3D kevent(skq, NULL, 0, &kev, 1, &(struct timespec) { 0= , 0 }); assert(rv =3D=3D 1); rv =3D kevent(skq, NULL, 0, &kev, 1, &(struct timespec) { 0= , 0 }); assert(rv =3D=3D 0); siginfo_t siginfo; rv =3D sigtimedwait(&set, &siginfo, &(struct timespec) { 0,= 0 }); assert(rv =3D=3D SIGUSR1); rv =3D sigtimedwait(&set, &siginfo, &(struct timespec) { 0,= 0 }); assert(rv < 0); assert(errno =3D=3D EAGAIN); } } ``` Is this behaviour expected or a bug? --=20 You are receiving this mail because: You are the assignee for the bug.=