diff --git a/CHANGELOG.md b/CHANGELOG.md index db64cf97..3de62c6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ All notable changes to this project will be documented in this file. ## Unreleased - ??? +- Add `upscope` special form. - `os/execute` and `os/spawn` can take streams for redirecting IO. - Add `;parser` and `:read` parameters to `run-context`. - Add `os/open` if ev is enabled. diff --git a/src/core/ev.c b/src/core/ev.c index 92b1667b..e95c324b 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -1317,9 +1317,16 @@ JanetAsyncStatus ev_machine_read(JanetListenerState *s, JanetAsyncEvent event) { /* Check for errors - special case errors that can just be waited on to fix */ if (nread == -1) { - if (errno == EAGAIN || errno == EWOULDBLOCK) break; - janet_cancel(s->fiber, janet_ev_lasterr()); - return JANET_ASYNC_STATUS_DONE; + if (errno == EAGAIN || errno == EWOULDBLOCK) { + return JANET_ASYNC_STATUS_NOT_DONE; + } + /* In stream protocols, a pipe error is end of stream */ + if (errno == EPIPE && (state->mode != JANET_ASYNC_READMODE_RECVFROM)) { + nread = 0; + } else { + janet_cancel(s->fiber, janet_ev_lasterr()); + return JANET_ASYNC_STATUS_DONE; + } } /* Only allow 0-length packets in recv-from. In stream protocols, a zero length packet is EOS. */