How linux.epoll_wait deal with the -1 case

since the return type of std.os.linux.epoll_wait is usize, how to deal with the -1 case.

boom!?
It seems to me the failure cases were deemed “you have a bigger, static problem that you ought to fix first”.

EBADF? Well, shouldn’t you know the fd is closed?
EINTR? We’ll auto-continue (I disagree with this choice personally, but I understand how it’s the likely wanted behaviour)
EINVAL? second half of error condition is taken care of by slices, first half is a “you shouldn’t be doing this anyways”
EFAULT, now that’s a “hmm”. I suppose you could work up a pointer to protected memory regions, but maybe fix that not-at-runtime?

What else do you wanna handle about epoll_wait’s -1?

1 Like

It is better to use std.posix.epoll_wait that handles the errors.
As @msw pointed, the sources of std.posix.epoll_wait show how to handle linux epoll_wait API.

It’s already been discussed somewhere, epoll is not a part of POSIX, it’s Linux specific and IMHO this part of stdlib should be reorganized back again.

1 Like

if i have a SIG.INT installed, the INT signal will make the return of linux.epoll_wait out of [0…events.len]