diff --git a/src/unix/core.c b/src/unix/core.c index 73027cbc5..c2d333237 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -643,7 +643,8 @@ int uv__close_nocheckstdio(int fd) { int uv__close(int fd) { - assert(fd > STDERR_FILENO); /* Catch stdio close bugs. */ + if (!uv__low_fd_flag) + assert(fd > STDERR_FILENO); /* Catch stdio close bugs. */ #if defined(__MVS__) SAVE_ERRNO(epoll_file_close(fd)); #endif diff --git a/src/unix/internal.h b/src/unix/internal.h index 80fe41f8e..125f10bdb 100644 --- a/src/unix/internal.h +++ b/src/unix/internal.h @@ -248,6 +248,8 @@ struct uv__statx { #define uv__nonblock uv__nonblock_fcntl #endif +extern int uv__low_fd_flag; + /* core */ int uv__cloexec(int fd, int set); int uv__nonblock_ioctl(int fd, int set); diff --git a/src/unix/linux.c b/src/unix/linux.c index 0e5c424ab..da682cbfc 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -275,6 +275,8 @@ struct watcher_root { struct watcher_list* rbh_root; }; +int uv__low_fd_flag = 0; + static int uv__inotify_fork(uv_loop_t* loop, struct watcher_list* root); static int compare_watchers(const struct watcher_list* a, const struct watcher_list* b); @@ -657,6 +659,9 @@ int uv__platform_loop_init(uv_loop_t* loop) { if (loop->backend_fd == -1) return UV__ERR(errno); + if (loop->backend_fd <= STDERR_FILENO) + uv__low_fd_flag = 1; + uv__iou_init(loop->backend_fd, &lfields->ctl, 256, 0); return 0;