aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/sys/kqueue.2
Commit message (Collapse)AuthorAgeFilesLines
* Remove $FreeBSD$: two-line nroff patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
* Change kqueue1() to be compatible with NetBSDKonstantin Belousov2023-04-051-0/+8
| | | | | | | | | | | by making it accept some open(2) flags. More precisely, only O_CLOEXEC is supported, the flag is translated into the KQUEUE_CLOEXEC flag for kqueuex(2), and O_NONBLOCK is silently ignored. Reported and tested by: vishwin Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39377
* kqueue: add close() calls to man page exampleEd Maste2023-04-041-0/+4
| | | | | | | | | | There is no real need to close descriptors before a process exits, but these close calls demonstrate by example that kqueue descriptors occupy the same namespace as other file descriptors. Reviewed by: fernape, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39376
* Rename kqueue1(2) to kqueuex(2) to avoid compat issues with NetBSDKonstantin Belousov2023-04-041-3/+3
| | | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39377
* kqueue: tidy up indentation in man page exampleEd Maste2023-03-311-2/+1
| | | | | Fixes: e07b0c12ba64 ("[patch][doc] Fix EXAMPLE in kqueue(2)") Sponsored by: The FreeBSD Foundation
* kqueue1(2): documentKonstantin Belousov2023-03-271-1/+19
| | | | | | | Reviewed by: emaste, jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39271
* kevent.2: Add an xref to listen.2Mark Johnston2022-06-201-1/+1
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation
* kqueue: Fix kqueue(2) man page.Dmitry Chagin2022-05-141-5/+1
| | | | | | | | | Remove bogus BUGS note about timeout limit to 24 hours, that's not true since callouting project import. Reviewed by: mav Differential revision: https://reviews.freebsd.org/D35206 MFC after: 2 weeks
* [patch][doc] Fix EXAMPLE in kqueue(2)Fernando Apesteguía2022-04-131-5/+7
| | | | | | | | | | | 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
* kqueue(2): Add note about format of the data for NOTE_EXITKonstantin Belousov2022-01-191-2/+4
| | | | | | | Noted by: Dave Baukus <daveb@spectralogic.com> PR: 261346 MFC after: 3 days Sponsored by: The FreeBSD Foundation
* bpf: Fix the write filter for detached descriptorsMark Johnston2021-10-261-2/+2
| | | | | | | | | | | | A BPF descriptor only has an associated interface descriptor once it is attached to an interface, e.g., with BIOCSETIF. Avoid dereferencing a NULL pointer in filt_bpfwrite() if the BPF descriptor is not attached. Reviewed by: ae Reported by: syzbot+ae45d5166afe15a5a21d@syzkaller.appspotmail.com Fixes: ded77e0237a8 ("Allow the BPF to be select for write.") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32561
* Allow the BPF to be select for write. This is needed for boost:asioHartmut Brandt2021-10-101-2/+7
| | | | | | which otherwise fails to handle BPFs. Reviewed by: ae Differential Revision: https://reviews.freebsd.org/D31967
* kqueue: clean up some igor and mandoc -Tlint warningsKyle Evans2021-10-011-4/+5
|
* kqueue: document how timers with low/past timeouts are handledKyle Evans2021-10-011-1/+7
| | | | | Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D32237
* kqueue: Add EV_KEEPUDATA flagNathaniel Wesley Filardo2021-09-241-1/+16
| | | | | | | | | | | When this flag is set, operations that update an existing kevent will not change the udata field. This can be used to NOTE_TRIGGER or EV_{EN,DIS}ABLE events without overwriting the stashed pointer. Reviewed by: Domagoj Stolfa <domagoj.stolfa@gmail.com> Obtained from: CheriBSD Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D30286
* kqueue.2: Document the fact that EVFILT_READ can be used on kqueuesMark Johnston2021-09-071-1/+5
| | | | | | | Reviewed by: bcr, kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31864
* kevent: Prohibit negative change and event list lengthsMark Johnston2021-05-271-1/+3
| | | | | | | | | | | | | Previously, a negative change list length would be treated the same as an empty change list. A negative event list length would result in bogus copyouts. Make kevent(2) return EINVAL for both cases so that application bugs are more easily found, and to be more robust against future changes to kevent internals. Reviewed by: imp, kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30480
* Document eventfd().Konstantin Belousov2020-12-271-1/+11
| | | | | | | Submitted by: greg@unrelenting.technology Reviewed by: bcr, markj (previous version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26668
* kqueue(2): Use .Fo instead .FtKonstantin Belousov2020-12-271-1/+8
| | | | | MFC after: 3 days Sponsored by: The FreeBSD Foundation
* libc manpages: various improvements from NetBSDGordon Bergling2020-06-141-1/+9
| | | | | | | | | | | | | | - Add STANDARDS and HISTORY sections within the appropriate manpages - Mention two USENIX papers within kqueue(2) and strlcpy(3) Reviewed by: bcr (mentor) Approved by: bcr (mentor) Obtained from: NetBSD MFC after: 7 days Differential Revision: https://reviews.freebsd.org/D24650 Notes: svn path=/head/; revision=362171
* Fix handling of EV_EOF for named pipes.Mark Johnston2020-04-271-6/+6
| | | | | | | | | | | | | | | | | | | | | | Contrary to the kevent man page, EV_EOF on a fifo is not cleared by EV_CLEAR. Modify the read and write filters to clear EV_EOF when the fifo's PIPE_EOF flag is clear, and update the man page to document the new behaviour. Modify the write filter to return the amount of buffer space available even if no readers are present. This matches the behaviour for sockets. When reading from a pipe, only call pipeselwakeup() if some data was actually read. This prevents the continuous re-triggering of a EVFILT_READ event on EOF when in edge-triggered mode. PR: 203366, 224615 Submitted by: Jan Kokemüller <jan.kokemueller@gmail.com> MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D24528 Notes: svn path=/head/; revision=360380
* kqueue(2): de-vandalize the random sentence in the middleKyle Evans2020-04-221-1/+2
| | | | | | | | | | A last minute change appears to have inadvertently vandalized unrelated parts of the manpage with the date. =-( Reported by: rpokala Notes: svn path=/head/; revision=360183
* kqueue(2): add a note about EV_RECEIPTKyle Evans2020-04-221-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | In the below-referenced PR, a case is attached of a simple reproducer that exhibits suboptimal behavior: EVFILT_READ and EVFILT_WRITE being set in the same kevent(2) call will only honor the first one. This is, in-fact, how it's supposed to work. A read of the manpage leads me to believe we could be more clear about this; right now there's a logical leap to make in the relevant statement: "When passed as input, it forces EV_ERROR to always be returned." -- the logical leap being that this indicates the caller should have allocated space for the change to be returned with EV_ERROR indicated in the events, or subsequent filters will get dropped on the floor. Another possible workaround that accomplishes similar effect without needing space for all events is just setting EV_RECEIPT on the final change being passed in; if any errored before it, the kqueue would not be drained. If we made it to the final change with EV_RECEIPT set, then we would return that one with EV_ERROR and still not drain the kqueue. This would seem to not be all that advisable. PR: 229741 MFC after: 1 week Notes: svn path=/head/; revision=360182
* Allow a EVFILT_TIMER kevent to be updated.David Bright2018-07-271-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a timer is updated (re-added) with a different time period (specified in the .data field of the kevent), the new time period has no effect; the timer will not expire until the original time has elapsed. This violates the documented behavior as the kqueue(2) man page says (in part) "Re-adding an existing event will modify the parameters of the original event, and not result in a duplicate entry." This modification, adapted from a patch submitted by cem@ to PR214987, fixes the kqueue system to allow updating a timer entry. The kevent timer behavior is changed to: * When a timer is re-added, update the timer parameters to and re-start the timer using the new parameters. * Allow updating both active and already expired timers. * When the timer has already expired, dequeue any undelivered events and clear the count of expirations. All of these changes address the original PR and also bring the FreeBSD and macOS kevent timer behaviors into agreement. A few other changes were made along the way: * Update the kqueue(2) man page to reflect the new timer behavior. * Fix man page style issues in kqueue(2) diagnosed by igor. * Update the timer libkqueue system test to test for the updated timer behavior. * Fix the (test) libkqueue common.h file so that it includes config.h which defines various HAVE_* feature defines, before the #if tests for such variables in common.h. This enables the use of the actual err(3) family of functions. * Fix the usages of the err(3) functions in the tests for incorrect type of variables. Those were formerly undiagnosed due to the disablement of the err(3) functions (see previous bullet point). PR: 214987 Reported by: Brian Wellington <bwelling@xbill.org> Reviewed by: kib MFC after: 1 week Relnotes: yes Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D15778 Notes: svn path=/head/; revision=336761
* Fix a few more speelling errorsEitan Adler2017-12-281-1/+1
| | | | | | | | | Reviewed by: bjk Reviewed by: jilles (incl formal "accept") Differential Revision: https://reviews.freebsd.org/D13650 Notes: svn path=/head/; revision=327259
* Note that old sys/event.h required manual sys/types.h inclusionBenjamin Kaduk2017-12-071-2/+3
| | | | | | | ed fixed this in r313704 but older versions are still affected. Notes: svn path=/head/; revision=326650
* Clarify usage of aio(4) with kqueue(2)Alan Somers2017-06-231-26/+11
| | | | | | | | | Reviewed by: jhb MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D11299 Notes: svn path=/head/; revision=320255
* Add abstime kqueue(2) timers and expand struct kevent members.Konstantin Belousov2017-06-171-6/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This change implements NOTE_ABSTIME flag for EVFILT_TIMER, which specifies that the data field contains absolute time to fire the event. To make this useful, data member of the struct kevent must be extended to 64bit. Using the opportunity, I also added ext members. This changes struct kevent almost to Apple struct kevent64, except I did not changed type of ident and udata, the later would cause serious API incompatibilities. The type of ident was kept uintptr_t since EVFILT_AIO returns a pointer in this field, and e.g. CHERI is sensitive to the type (discussed with brooks, jhb). Unlike Apple kevent64, symbol versioning allows us to claim ABI compatibility and still name the new syscall kevent(2). Compat shims are provided for both host native and compat32. Requested by: bapt Reviewed by: bapt, brooks, ngie (previous version) Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D11025 Notes: svn path=/head/; revision=320043
* Move the description of kern.kq_calloutmax sysctl into a new paragraphKonstantin Belousov2017-06-161-4/+5
| | | | | | | | | | for better presentation. Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=320035
* Start a new sentence on the new line.Konstantin Belousov2017-06-161-1/+2
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=320034
* Document kevent EVFILT_EMPTY.Sergey Kandaurov2017-04-181-1/+4
| | | | | | | | Reviewed by: hiren X-MFC with: r312277 Notes: svn path=/head/; revision=317091
* Remove unnecessary #includes from the kqueue(2) man page.Ed Schouten2017-02-161-6/+7
| | | | | | | | | | | | | | | Now that <sys/event.h> can be included on its own, adjust the manual page accordingly. Remove both unnecessary #include statements from the synopsis and the example code. While there, also add a note to the BUGS section to mention that previous versions of this header file still depend on <sys/types.h>. Reviewed by: ngie, vangyzen Differential Revision: https://reviews.freebsd.org/D9605 Notes: svn path=/head/; revision=313801
* Improve grammar.Bryan Drewery2016-10-061-1/+1
| | | | | | | | MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=306771
* Correct wording.Konstantin Belousov2016-05-031-1/+1
| | | | | | | | Submitted by: David A. Bright MFC after: 2 weeks Notes: svn path=/head/; revision=298984
* Add EVFILT_VNODE open, read and close notifications.Konstantin Belousov2016-05-031-8/+26
| | | | | | | | | | While there, order EVFILT_VNODE notes descriptions alphabetically. Based on submission, and tested by: Vladimir Kondratyev <wulf@cicgroup.ru> MFC after: 2 weeks Notes: svn path=/head/; revision=298982
* Issue NOTE_EXTEND when a directory entry is added to or removed fromKonstantin Belousov2016-05-021-2/+8
| | | | | | | | | | | the monitored directory as the result of rename(2) operation. The renames staying in the directory are not reported. Submitted by: Vladimir Kondratyev <wulf@cicgroup.ru> MFC after: 2 weeks Notes: svn path=/head/; revision=298922
* As a reader service, explain NOTE_LINK reporting for the directories.Konstantin Belousov2016-05-011-0/+4
| | | | | | | | Submitted by: Vladimir Kondratyev <wulf@cicgroup.ru> MFC after: 1 week Notes: svn path=/head/; revision=298898
* Provide an example to the kqueue man page, showingBenedict Reuschling2016-05-011-1/+52
| | | | | | | | | | | | | | | | a basic usage example. Although it is an untypical example for the use of kqueue, it is better than nothing and should get people started. PR: 196844 Submitted by: fernando.apesteguia@gmail.com Reviewed by: kib Approved by: kib MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D6082 Notes: svn path=/head/; revision=298893
* Make it possible to implement poll(2) on top of kqueue(2).Ed Schouten2015-08-051-1/+9
| | | | | | | | | | | | | | | | | It looks like EVFILT_READ and EVFILT_WRITE trigger under the same conditions as poll()'s POLLRDNORM and POLLWRNORM as described by POSIX. The only difference is that POLLRDNORM has to be triggered on regular files unconditionally, whereas EVFILT_READ only triggers when not EOF. Introduce a new flag, NOTE_FILE_POLL, that can be used to make EVFILT_READ and EVFILT_WRITE behave identically to poll(). This flag will be used by cloudlibc's poll() function. Reviewed by: jmg Differential Revision: https://reviews.freebsd.org/D3303 Notes: svn path=/head/; revision=286307
* Make kevent(2) a cancellation point.Konstantin Belousov2015-03-291-2/+23
| | | | | | | | | | | | | | | | | | | | | | | | Note that to cancel blocked kevent(2) call, changelist must be empty, since we cannot cancel a call which already made changes to the process state. And in reverse, call which only makes changes to the kqueue state, without waiting for an event, is not cancellable. This makes a natural usage model to migrate kqueue loop to support cancellation, where existing single kevent(2) call must be split into two: first uncancellable update of kqueue, then cancellable wait for events. Note that this is ABI-incompatible change, but it is believed that there is no cancel-safe code that relies on kevent(2) not being a cancellation point. Option to preserve the ABI would be to keep kevent(2) as is, but add new call with flags to specify cancellation behaviour, which only value seems to add complications. Suggested and reviewed by: jilles Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=280818
* Markup fixes for kqueue(2), no content changes.Konstantin Belousov2014-12-151-61/+87
| | | | | | | | | Reviewed by: brueffer (previous version) Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=275806
* Minor mdoc nit.Joel Dahl2014-09-091-1/+0
| | | | Notes: svn path=/head/; revision=271315
* Extend kqueue's EVFILT_TIMER by adding precision unit flags supportBaptiste Daroussin2014-07-181-3/+20
| | | | | | | | | | | | Define the precision macros as bits sets to conform with XNU equivalent. Test fflags passed for EVFILT_TIMER and return EINVAL in case an invalid flag is passed. Phabric: https://phabric.freebsd.org/D421 Reviewed by: kib Notes: svn path=/head/; revision=268843
* use .Mt to mark up email addresses consistently (part4)Baptiste Daroussin2014-06-231-1/+1
| | | | | | | | PR: 191174 Submitted by: Franco Fichtner <franco at lastsummer.de> Notes: svn path=/head/; revision=267774
* Fix table alignment. EVFILT_PROCDESC is longer than the existing filters.Ed Schouten2014-04-071-1/+1
| | | | Notes: svn path=/head/; revision=264232
* Implement kqueue(2) for procdesc(4).Ed Schouten2014-04-071-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | kqueue(2) already supports EVFILT_PROC. Add an EVFILT_PROCDESC that behaves the same, but operates on a procdesc(4) instead. Only implement NOTE_EXIT for now. The nice thing about NOTE_EXIT is that it also returns the exit status of the process, meaning that we can now obtain this value, even if pdwait4(2) is still unimplemented. Notes: - Simply reuse EVFILT_NETDEV for EVFILT_PROCDESC. As both of these will be used on totally different descriptor types, this should not clash. - Let procdesc_kqops_event() reuse the same structure as filt_proc(). The only difference is that procdesc_kqops_event() should also be able to deal with the case where the process was already terminated after registration. Simply test this when hint == 0. - Fix some style(9) issues in filt_proc() to keep it consistent with the newly added procdesc_kqops_event(). - Save the exit status of the process in pd->pd_xstat, as we cannot pick up the proctree_lock from within procdesc_kqops_event(). Discussed on: arch@ Reviewed by: kib@ Notes: svn path=/head/; revision=264231
* kqueue: Change error for kqueues rlimit from EMFILE to ENOMEM and documentJilles Tjoelker2013-11-031-1/+8
| | | | | | | | | this error condition in the kqueue(2) manual page. Discussed with: kib Notes: svn path=/head/; revision=257597
* Enhance the description of NOTE_TRACK:John Baldwin2013-07-251-6/+11
| | | | | | | | | | | | | | | | | - NOTE_TRACK has never triggered a NOTE_TRACK event from the parent pid. If NOTE_FORK is set, the listener will get a NOTE_FORK event from the parent pid, but not a separate NOTE_TRACK event. - Explicitly note that the event added to monitor the child process preserves the fflags from the original event. - Move the description of NOTE_TRACKERR under NOTE_TRACK as it is not a bit for the user to set (which is what this list pupports to be). Also, explicitly note that if an error occurs, the NOTE_CHILD event will not be generated. MFC after: 1 week Notes: svn path=/head/; revision=253656
* Note that SIGCHLD is special and if ignored, won't be recorded by the filter.Pawel Jakub Dawidek2013-01-211-2/+4
| | | | Notes: svn path=/head/; revision=245750
* Remove trailing whitespace per mdoc lint warningEitan Adler2012-03-291-4/+4
| | | | | | | | | | Disussed with: gavin No objection from: doc Approved by: joel MFC after: 3 days Notes: svn path=/head/; revision=233648