diff --git a/source/eventcore/drivers/posix/epoll.d b/source/eventcore/drivers/posix/epoll.d index b6a5767..1abb020 100644 --- a/source/eventcore/drivers/posix/epoll.d +++ b/source/eventcore/drivers/posix/epoll.d @@ -57,7 +57,16 @@ final class EpollEventLoop : PosixEventLoop { if (evt.events & EPOLLOUT) notify!(EventType.write)(fd); } return true; - } else return false; + } else { + // NOTE: In particular, EINTR needs to cause true to be returned + // here, so that user code has a chance to handle any effects + // of the signal handler before waiting again. + // + // Other errors are very likely to to reoccur for the next + // loop iteration, so there is no value in attempting to + // wait again. + return ret < 0; + } } override void dispose() diff --git a/source/eventcore/drivers/posix/kqueue.d b/source/eventcore/drivers/posix/kqueue.d index 3692e83..800f4b9 100644 --- a/source/eventcore/drivers/posix/kqueue.d +++ b/source/eventcore/drivers/posix/kqueue.d @@ -85,7 +85,16 @@ abstract class KqueueEventLoopBase : PosixEventLoop { // EV_SIGNAL, EV_TIMEOUT } return true; - } else return false; + } else { + // NOTE: In particular, EINTR needs to cause true to be returned + // here, so that user code has a chance to handle any effects + // of the signal handler before waiting again. + // + // Other errors are very likely to to reoccur for the next + // loop iteration, so there is no value in attempting to + // wait again. + return ret < 0; + } } override void dispose() diff --git a/source/eventcore/drivers/posix/select.d b/source/eventcore/drivers/posix/select.d index dabc491..60a8380 100644 --- a/source/eventcore/drivers/posix/select.d +++ b/source/eventcore/drivers/posix/select.d @@ -65,7 +65,16 @@ final class SelectEventLoop : PosixEventLoop { notify!(EventType.status)(fd); }); return true; - } else return false; + } else { + // NOTE: In particular, EINTR needs to cause true to be returned + // here, so that user code has a chance to handle any effects + // of the signal handler before waiting again. + // + // Other errors are very likely to to reoccur for the next + // loop iteration, so there is no value in attempting to + // wait again. + return ret < 0; + } } override void dispose()