I recently got into using kevent(). Reading the manpage (as of FreeBSD 14.0), I'm left with a lot of questions and I didn't find better documentation yet.
In particular, the following questions remain unclear to me:
Maybe I'm just having difficulties in understanding/interpreting the manpage, but I feel like it's suboptimally written. Is there any better (ideally authoritative/normative) documentation on this subject?
In particular, the following questions remain unclear to me:
- What is the purpose of
EV_ENABLEandEV_DISABLE(in contrast to deleting an event withEV_DELETEwhen no longer needed). Is this performance related only, or are there any other effects when disabling an event temporarily (either manually or throughEV_DISPATCH) instead of removing it (e.g. withEV_ONESHOTor manually)? - Why does the manpage mention the "remaining space in eventlist" in regard to
EV_RECEIPT, and explains that when it's too small "subsequent changes will not get processed"? As far as I understand,EV_RECEIPTshould avoid "draining any pending events". So how could the space be exhausted (other than being too small in the first place)? I don't understand what the word "remaining" means here. - What is the purpose of not specifying
EV_CLEARfor those events where it's not implicitly enabled? How long would an event be reported as pending? Until I disable the event? Until I delete the event? Is there any way to "acknowledge" the event? Bonus question: Which events in particular "report state transitions instead of the current state" (as written in the manpage)? - Which flags are used as an input (in
struct kevent *changelistand which flags are an output (instruct kevent *eventlist)? I assume thatEV_EOFandEV_ERRORare only outputs and all other flags are only used as inputs? Is there any reason why all flags listed in the same list on the manpage? Is it correct that no flag is used both as input and output? - Monitoring a process to exit (
EVFILT_PROCwithNOTE_EXIT) results in the process' exit status (to be checked withWIFEXITEDand related macros) to be returned in thedatafield of thestruct keventin theeventlist. However, the manpage is unclear about whether the process' status is collected or not. Do I have to subsequently call waitpid() to reap zombie processes? Does the behavior depend onEV_ONESHOTorEV_CLEAR, or any other flags?
Maybe I'm just having difficulties in understanding/interpreting the manpage, but I feel like it's suboptimally written. Is there any better (ideally authoritative/normative) documentation on this subject?