[Bug 258310] kevent() does not see signal with zero timeout
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 258310] kevent() does not see signal with zero timeout"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 258310] kevent() does not see signal with zero timeout"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 258310] kevent() does not see signal with zero timeout"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 258310] kevent() does not see signal with zero timeout"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 258310] kevent() does not see signal with zero timeout"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Sep 2021 10:50:30 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258310 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 Jan Kokemüller provided a reduced test case using only kqueue and kevent: ``` #ifdef NDEBUG #undef NDEBUG #endif #define _GNU_SOURCE #include <sys/types.h> #include <sys/event.h> #include <assert.h> #include <errno.h> #include <signal.h> #include <stdlib.h> #include <poll.h> #include <unistd.h> int main(void) { int rv; sigset_t set; rv = sigemptyset(&set); assert(rv == 0); rv = sigaddset(&set, SIGUSR1); assert(rv == 0); rv = sigprocmask(SIG_BLOCK, &set, NULL); assert(rv == 0); int skq = kqueue(); assert(skq >= 0); struct kevent kev; EV_SET(&kev, SIGUSR1, EVFILT_SIGNAL, EV_ADD, 0, 0, 0); rv = kevent(skq, &kev, 1, NULL, 0, NULL); assert(rv == 0); int kq = kqueue(); assert(kq >= 0); EV_SET(&kev, skq, EVFILT_READ, EV_ADD | EV_CLEAR, 0, 0, 0); rv = kevent(kq, &kev, 1, NULL, 0, NULL); assert(rv == 0); for (;;) { rv = kill(getpid(), SIGUSR1); assert(rv == 0); /* Turn this into `#if 1` to avoid the race. */ #if 0 rv = kevent(kq, NULL, 0, &kev, 1, NULL); #else rv = kevent(kq, NULL, 0, &kev, 1, &(struct timespec) { 0, 0 }); #endif assert(rv == 1); rv = kevent(kq, NULL, 0, &kev, 1, &(struct timespec) { 0, 0 }); assert(rv == 0); rv = kevent(skq, NULL, 0, &kev, 1, &(struct timespec) { 0, 0 }); assert(rv == 1); rv = kevent(skq, NULL, 0, &kev, 1, &(struct timespec) { 0, 0 }); assert(rv == 0); siginfo_t siginfo; rv = sigtimedwait(&set, &siginfo, &(struct timespec) { 0, 0 }); assert(rv == SIGUSR1); rv = sigtimedwait(&set, &siginfo, &(struct timespec) { 0, 0 }); assert(rv < 0); assert(errno == EAGAIN); } } ``` Is this behaviour expected or a bug? -- You are receiving this mail because: You are the assignee for the bug.