diff --git a/src/core/ev.c b/src/core/ev.c index 5d4e04c5..0303a36e 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -3308,16 +3308,15 @@ static JanetFile *get_file_for_stream(JanetStream *stream) { if (fd_dup < 0) return NULL; FILE *f = _fdopen(fd_dup, fmt); if (NULL == f) { - /* the stream isn't duplicated so this would close the stream - * _close(fd); */ + _close(fd_dup); return NULL; } #else - int newHandle = dup(stream->handle); - if (newHandle < 0) return NULL; - FILE *f = fdopen(newHandle, fmt); + int fd_dup = dup(stream->handle); + if (fd_dup < 0) return NULL; + FILE *f = fdopen(fd_dup, fmt); if (NULL == f) { - close(newHandle); + close(fd_dup); return NULL; } #endif @@ -3329,17 +3328,10 @@ JANET_CORE_FN(janet_cfun_to_file, "Create core/file copy of the stream. This value can be used " "when blocking IO behavior is needed.") { janet_fixarity(argc, 1); -#ifdef JANET_MINGW - (void) argc; - (void) argv; - janet_panic("ev/to-file not supported on MinGW"); - return janet_wrap_nil(); -#else JanetStream *stream = janet_getabstract(argv, 0, &janet_stream_type); JanetFile *iof = get_file_for_stream(stream); if (iof == NULL) janet_panic("cannot make file from stream"); return janet_wrap_abstract(iof); -#endif } JANET_CORE_FN(janet_cfun_ev_all_tasks,