1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-17 22:24:49 +00:00

Add EV_EOF for kqueue.

This commit is contained in:
Calvin Rose 2023-10-06 17:39:52 -05:00
parent 6186be4443
commit e7e4341e70

View File

@ -1665,7 +1665,7 @@ static void timestamp2timespec(struct timespec *t, JanetTimestamp ts) {
void janet_register_stream(JanetStream *stream) { void janet_register_stream(JanetStream *stream) {
struct kevent kev; struct kevent kev;
EV_SETx(&kev, stream->handle, EVFILT_READ | EVFILT_WRITE, EV_ADD | EV_ENABLE | EV_CLEAR, 0, 0, stream); EV_SETx(&kev, stream->handle, EVFILT_READ | EVFILT_WRITE, EV_ADD | EV_ENABLE | EV_CLEAR | EV_EOF, 0, 0, stream);
int status; int status;
do { do {
status = kevent(janet_vm.kq, &kev, 1, NULL, 0, NULL); status = kevent(janet_vm.kq, &kev, 1, NULL, 0, NULL);
@ -1698,8 +1698,9 @@ void janet_loop1_impl(int has_timeout, JanetTimestamp timeout) {
JANET_KQUEUE_MAX_EVENTS, NULL); JANET_KQUEUE_MAX_EVENTS, NULL);
} }
} while (status == -1 && errno == EINTR); } while (status == -1 && errno == EINTR);
if (status == -1) if (status == -1) {
JANET_EXIT("failed to poll events"); JANET_EXIT("failed to poll events");
}
/* Make sure timer is set accordingly. */ /* Make sure timer is set accordingly. */
janet_vm.timer_enabled = has_timeout; janet_vm.timer_enabled = has_timeout;