diff options
| author | Fernando ApesteguĂa <fernape@FreeBSD.org> | 2022-04-11 18:40:28 +0000 |
|---|---|---|
| committer | Fernando ApesteguĂa <fernape@FreeBSD.org> | 2022-04-13 06:01:58 +0000 |
| commit | e07b0c12ba6435421ceb7dd028402d5cbfc1f1dd (patch) | |
| tree | 2c607475713e2c4b2812b75b0ab5aac0aeb5d3e0 | |
| parent | f8058d33337425549e42dcccdd0f55c837bb8775 (diff) | |
| download | src-e07b0c12ba6435421ceb7dd028402d5cbfc1f1dd.tar.gz src-e07b0c12ba6435421ceb7dd028402d5cbfc1f1dd.zip | |
[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
| -rw-r--r-- | lib/libc/sys/kqueue.2 | 12 |
1 files 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 |
