clarification on kqueue kernel event flags.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 15 Oct 2022 21:55:30 UTC
Hello,
I got confused with EV_CLEAR flag. Some code follows.
kev.ident = 1;
kev.filter = EVFILT_TIMER;
kev.flags = EV_ADD | EV_DISPATCH;
kev.data = 4;
kev.fflags = NOTE_SECONDS;
l_reg_ev:
status = kevent(kq, &kev, 1, NULL, 0, NULL);
for(;;){
status = kevent(kq, NULL, 0, &kev, 1, NULL);
kev.flags = EV_ENABLE;
goto l_reg_ev;
}
This prints the series of:
id : 1
> flags : EV_DISPATCH EV_CLEAR
> filter : EVFILT_TIMER
> data : # times timeout has expired since last kevent call: 1
>
The "man kevent", the EV_CLEAR section says that:
> After the event is retrieved by the user, its state is reset.
>
What I expect is that after the first goto, the EV_DISPATCH flag gets
cleared. What does "the state" mean in the above?
More specifically, what exactly EV_CLEAR changes with any combination of
flags and filters?
P.S.
I did read a source code for "/sys/kern/kern_event.c". My brain fails to
understand it as a whole, so, please be easy on me.
--
Ярослав Машко
+380 50 56 75 347 <+380+50+56+75+347>