pub fn kevent(
kq: i32,
changelist: []const posix.Kevent,
eventlist: []posix.Kevent,
timeout: ?*const posix.timespec,
) KEventError!usize AccessDeniedThe process does not have permission to register a filter.
EventNotFoundThe event could not be found to be modified or deleted.
SystemResourcesNo memory was available to register the event.
ProcessNotFoundThe specified process to attach to does not exist.
Overflowchangelist or eventlist had too many items on it. TODO remove this possibility
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502pub fn kevent(
kq: i32,
changelist: []const posix.Kevent,
eventlist: []posix.Kevent,
timeout: ?*const posix.timespec,
) KEventError!usize {
while (true) {
const rc = posix.system.kevent(
kq,
changelist.ptr,
std.math.cast(c_int, changelist.len) orelse return error.Overflow,
eventlist.ptr,
std.math.cast(c_int, eventlist.len) orelse return error.Overflow,
timeout,
);
switch (posix.errno(rc)) {
.SUCCESS => return @intCast(rc),
.ACCES => return error.AccessDenied,
.FAULT => unreachable, // TODO use error.Unexpected for these
.BADF => unreachable, // Always a race condition.
.INTR => continue, // TODO handle cancelation
.INVAL => unreachable,
.NOENT => return error.EventNotFound,
.NOMEM => return error.SystemResources,
.SRCH => return error.ProcessNotFound,
else => unreachable,
}
}
}