diff --git a/src/unix/core.c b/src/unix/core.c index 1154fa25..b4cb948b 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -444,6 +444,10 @@ int uv__nonblock(int fd, int set) { if (r == -1) return -1; + /* Bail out now if already set/clear. */ + if (!!(r & O_NONBLOCK) == !!set) + return 0; + if (set) flags = r | O_NONBLOCK; else @@ -468,6 +472,10 @@ int uv__cloexec(int fd, int set) { if (r == -1) return -1; + /* Bail out now if already set/clear. */ + if (!!(r & FD_CLOEXEC) == !!set) + return 0; + if (set) flags = r | FD_CLOEXEC; else