git: e07b0c12ba64 - main - [patch][doc] Fix EXAMPLE in kqueue(2)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 13 Apr 2022 06:04:33 UTC
The branch main has been updated by fernape (doc, ports committer):
URL: https://cgit.FreeBSD.org/src/commit/?id=e07b0c12ba6435421ceb7dd028402d5cbfc1f1dd
commit e07b0c12ba6435421ceb7dd028402d5cbfc1f1dd
Author: Fernando Apesteguía <fernape@FreeBSD.org>
AuthorDate: 2022-04-11 18:40:28 +0000
Commit: Fernando Apesteguía <fernape@FreeBSD.org>
CommitDate: 2022-04-13 06:01:58 +0000
[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 <pauamma@gundo.com>
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