From e07b0c12ba6435421ceb7dd028402d5cbfc1f1dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Apestegu=C3=ADa?= Date: Mon, 11 Apr 2022 20:40:28 +0200 Subject: [PATCH] [patch][doc] Fix EXAMPLE in kqueue(2) The error control was not properly implemented. "changelist" is const, hence event.flags is never changed by the syscall. PR: 196844 Reported by: eugen@ Reviewed by: PauAmma Approved by: eugen@ Fixes: 8c231786f01b9f8614e2fe5b47196db1caa7a772 --- lib/libc/sys/kqueue.2 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2 index 8ba1779c5551..b4531b6cd02b 100644 --- a/lib/libc/sys/kqueue.2 +++ b/lib/libc/sys/kqueue.2 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 20, 2022 +.Dd April 13, 2022 .Dt KQUEUE 2 .Os .Sh NAME @@ -742,8 +742,6 @@ main(int argc, char **argv) ret = kevent(kq, &event, 1, NULL, 0, NULL); if (ret == -1) err(EXIT_FAILURE, "kevent register"); - if (event.flags & EV_ERROR) - errx(EXIT_FAILURE, "Event error: %s", strerror(event.data)); for (;;) { /* Sleep until something happens. */ @@ -751,8 +749,12 @@ main(int argc, char **argv) if (ret == -1) { err(EXIT_FAILURE, "kevent wait"); } else if (ret > 0) { - printf("Something was written in '%s'\en", argv[1]); - } + if (tevent.flags & EV_ERROR) + errx(EXIT_FAILURE, "Event error: %s", strerror(event.data)); + else + printf("Something was written in '%s'\en", argv[1]); +} + } } .Ed