#include <sys/event.h>
sys/event.h
macroEVFILT_WRITE
#define EVFILT_WRITE (-2)
macroEVFILT_SYSCOUNT
#define EVFILT_SYSCOUNT 18
structkevent
| uintptr_t | ident | identifier for this event |
| int16_t | filter | filter for event |
| uint16_t | flags | general flags |
| uint32_t | fflags | filter-specific flags |
| intptr_t | data | filter-specific data |
| void * | udata | opaque user data identifier |
structkevent64_s
| uint64_t | ident | identifier for this event |
| int16_t | filter | filter for event |
| uint16_t | flags | general flags |
| uint32_t | fflags | filter-specific flags |
| int64_t | data | filter-specific data |
| uint64_t | udata | opaque user data identifier |
| uint64_t[2] | ext | filter-specific extensions |
macroEV_SET
#define EV_SET(kevp, a, b, c, d, e, f) do {
struct kevent *__kevp__ = (kevp);
__kevp__->ident = (a);
__kevp__->filter = (b);
__kevp__->flags = (c);
__kevp__->fflags = (d);
__kevp__->data = (e);
__kevp__->udata = (f);
} while(0)macroEV_SET64
#define EV_SET64(kevp, a, b, c, d, e, f, g, h) do {
struct kevent64_s *__kevp__ = (kevp);
__kevp__->ident = (a);
__kevp__->filter = (b);
__kevp__->flags = (c);
__kevp__->fflags = (d);
__kevp__->data = (e);
__kevp__->udata = (f);
__kevp__->ext[0] = (g);
__kevp__->ext[1] = (h);
} while(0)macroKEVENT_FLAG_ERROR_EVENTS
#define KEVENT_FLAG_ERROR_EVENTS 0x000002
output events only include change errors
macroEV_DISPATCH2
#define EV_DISPATCH2 (EV_DISPATCH | EV_UDATA_SPECIFIC)
macroEV_POLL
Filter specific flags for EVFILT_READ
The default behavior for EVFILT_READ is to make the "read" determination
relative to the current file descriptor read pointer.
The EV_POLL flag indicates the determination should be made via poll(2)
semantics. These semantics dictate always returning true for regular files,
regardless of the amount of unread data in the file.
On input, EV_OOBAND specifies that filter should actively return in the
presence of OOB on the descriptor. It implies that filter will return
if there is OOB data available to read OR when any other condition
for the read are met (for example number of bytes regular data becomes >=
low-watermark).
If EV_OOBAND is not set on input, it implies that the filter should not actively
return for out of band data on the descriptor. The filter will then only return
when some other condition for read is met (ex: when number of regular data bytes
>=low-watermark OR when socket can't receive more data (SS_CANTRCVMORE)).
On output, EV_OOBAND indicates the presence of OOB data on the descriptor.
If it was not specified as an input parameter, then the data count is the
number of bytes before the current OOB marker, else data count is the number
of bytes beyond OOB marker.
#define EV_POLL EV_FLAG0
macroNOTE_TRIGGER
On input, NOTE_TRIGGER causes the event to be triggered for output.
#define NOTE_TRIGGER 0x01000000
macroNOTE_FFNOP
On input, the top two bits of fflags specifies how the lower twenty four
bits should be applied to the stored value of fflags.
On output, the top two bits will always be set to NOTE_FFNOP and the
remaining twenty four bits will contain the stored fflags value.
#define NOTE_FFNOP 0x00000000
ignore input fflags
macroNOTE_FFLAGSMASK
#define NOTE_FFLAGSMASK 0x00ffffff
macroNOTE_LOWAT
data/hint fflags for EVFILT_{READ|WRITE}, shared with userspace
The default behavior for EVFILT_READ is to make the determination
realtive to the current file descriptor read pointer.
#define NOTE_LOWAT 0x00000001
low water mark
macroNOTE_OOB
data/hint flags for EVFILT_EXCEPT, shared with userspace
#define NOTE_OOB 0x00000002
OOB data
macroNOTE_DELETE
data/hint fflags for EVFILT_VNODE, shared with userspace
#define NOTE_DELETE 0x00000001
vnode was removed
macroNOTE_NONE
#define NOTE_NONE 0x00000080
No specific vnode event: to test for EVFILT_READ activation
enum(anonymous)
data/hint fflags for EVFILT_PROC, shared with userspace
Please note that EVFILT_PROC and EVFILT_SIGNAL share the same knote list
that hangs off the proc structure. They also both play games with the hint
passed to KNOTE(). If NOTE_SIGNAL is passed as a hint, then the lower bits
of the hint contain the signal. IF NOTE_FORK is passed, then the lower bits
contain the PID of the child (but the pid does not get passed through in
the actual kevent).
| eNoteReapDeprecated | 268435456 |
macroNOTE_EXITSTATUS
#define NOTE_EXITSTATUS 0x04000000
exit status to be returned, valid for child process or when allowed to signal target pid
macroNOTE_PCTRLMASK
#define NOTE_PCTRLMASK (~NOTE_PDATAMASK)
enum(anonymous)
If NOTE_EXITSTATUS is present, provide additional info about exiting process.
| eNoteExitReparentedDeprecated | 524288 |
macroNOTE_EXIT_REPARENTED
#define NOTE_EXIT_REPARENTED ((unsigned int)eNoteExitReparentedDeprecated)
exited while reparented
macroNOTE_EXIT_DETAIL_MASK
If NOTE_EXIT_DETAIL is present, these bits indicate specific reasons for exiting.
#define NOTE_EXIT_DETAIL_MASK 0x00070000
macroNOTE_EXIT_DECRYPTFAIL
#define NOTE_EXIT_DECRYPTFAIL 0x00010000
macroNOTE_EXIT_MEMORY
#define NOTE_EXIT_MEMORY 0x00020000
macroNOTE_EXIT_CSERROR
#define NOTE_EXIT_CSERROR 0x00040000
macroNOTE_VM_PRESSURE
data/hint fflags for EVFILT_VM, shared with userspace.
#define NOTE_VM_PRESSURE 0x80000000
will react on memory pressure
macroNOTE_VM_PRESSURE_TERMINATE
#define NOTE_VM_PRESSURE_TERMINATE 0x40000000
will quit on memory pressure, possibly after cleaning up dirty state
macroNOTE_VM_PRESSURE_SUDDEN_TERMINATE
#define NOTE_VM_PRESSURE_SUDDEN_TERMINATE 0x20000000
will quit immediately on memory pressure
macroNOTE_SECONDS
data/hint fflags for EVFILT_TIMER, shared with userspace.
The default is a (repeating) interval timer with the data
specifying the timeout interval in milliseconds.
All timeouts are implicitly EV_CLEAR events.
#define NOTE_SECONDS 0x00000001
data is seconds
macroNOTE_LEEWAY
... implicit EV_ONESHOT, timeout uses the gettimeofday epoch
#define NOTE_LEEWAY 0x00000010
ext[1] holds leeway for power aware timers
macroNOTE_MACH_CONTINUOUS_TIME
#define NOTE_MACH_CONTINUOUS_TIME 0x00000080
macroNOTE_MACHTIME
NOTE_MACH_CONTINUOUS_TIME:
with NOTE_ABSOLUTE: causes the timer to continue to tick across sleep,
still uses gettimeofday epoch
with NOTE_MACHTIME and NOTE_ABSOLUTE: uses mach continuous time epoch
without NOTE_ABSOLUTE (interval timer mode): continues to tick across sleep
#define NOTE_MACHTIME 0x00000100
data is mach absolute time units
macroNOTE_TRACK
DEPRECATED!!!!!!!!!
NOTE_TRACK, NOTE_TRACKERR, and NOTE_CHILD are no longer supported as of 10.5
additional flags for EVFILT_PROC
#define NOTE_TRACK 0x00000001
follow across forks
structklist
| struct knote * | slh_first | first element |
functionkqueue
int kqueue(void)
man page · October 21, 2008
kqueue(2) — kernel event notification mechanismfunctionkevent
int kevent( int kq, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout )
man page · October 21, 2008
kevent(2) — kernel event notification mechanismfunctionkevent64
int kevent64( int kq, const struct kevent64_s *changelist, int nchanges, struct kevent64_s *eventlist, int nevents, unsigned int flags, const struct timespec *timeout )
man page · October 21, 2008
kevent64(2) — kernel event notification mechanism