FreeBSD Bugzilla – Attachment 169639 Details for
Bug 196844
[patch][doc] Add EXAMPLES section to kqueue(2) man page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch to kqueue(2) man page
kqueue.2.patch (text/plain), 1.39 KB, created by
Fernando ApesteguĂa
on 2016-04-24 18:26:34 UTC
(
hide
)
Description:
patch to kqueue(2) man page
Filename:
MIME Type:
Creator:
Fernando ApesteguĂa
Created:
2016-04-24 18:26:34 UTC
Size:
1.39 KB
patch
obsolete
>--- kqueue.2.orig 2016-04-24 19:21:21.658115000 +0200 >+++ kqueue.2 2016-04-24 19:26:35.036673000 +0200 >@@ -577,6 +577,58 @@ > If the time limit expires, then > .Fn kevent > returns 0. >+.Sh EXAMPLES >+.Bd -literal -compact >+#include <sys/types.h> >+#include <sys/event.h> >+#include <sys/time.h> >+#include <err.h> >+#include <fcntl.h> >+#include <stdio.h> >+#include <stdlib.h> >+#include <string.h> >+#include <unistd.h> >+ >+int >+main(int argc, char **argv) >+{ >+ >+ struct kevent event; /* Event we want to monitor */ >+ struct kevent tevent; /* Event triggered */ >+ int kq, fd, ret; >+ >+ if (argc != 2) { >+ err(EXIT_FAILURE, "Usage: %s path\en", argv[0]); >+ } >+ >+ if ((fd = open(argv[1], O_RDONLY)) == -1) { >+ err(EXIT_FAILURE, "Failed to open '%s'", argv[1]); >+ } >+ >+ /* Create kqueue */ >+ if ((kq = kqueue()) == -1) { >+ err(EXIT_FAILURE, "kqueue() failed"); >+ } >+ >+ /* Initialize kevent structure */ >+ EV_SET(&event, fd, EVFILT_VNODE , EV_ADD | EV_ONESHOT, NOTE_WRITE, 0, NULL); >+ >+ for (;;) { >+ /* Attach event to the kqueue and block until something happens */ >+ ret = kevent(kq, &event, 1, &tevent, 1, NULL); >+ if (ret == -1) { >+ perror("kevent"); >+ exit(EXIT_FAILURE); >+ } else if (ret > 0) { >+ if (event.flags & EV_ERROR) { >+ fprintf(stderr, "Event error: %s\en", strerror(event.data)); >+ } else { >+ printf("Something was written in '%s'\en", argv[1]); >+ } >+ } >+ } >+} >+.Ed > .Sh ERRORS > The > .Fn kqueue
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 196844
:
151802
| 169639 |
169715
|
233152
|
233158