From 9bbc1137eee705b818f145c3819e1383771fcbb2 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 5 Nov 2015 17:06:53 +0100 Subject: [PATCH] unix: don't retry dup2/dup3 on EINTR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Like the previous commit, but this time for UNIX platforms other than Linux. As far as I have been able to establish, dup2 and dup3 never return EINTR on OS X and FreeBSD. Even if other platforms do return EINTR, it's probably still better not to retry because it's unspecified whether the file descriptor has been closed. Fixes: https://github.com/libuv/libuv/issues/462 PR-URL: https://github.com/libuv/libuv/pull/608 Reviewed-By: Saúl Ibarra Corretgé --- src/unix/core.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/unix/core.c b/src/unix/core.c index efbb85d4..a06a8c16 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -960,16 +960,12 @@ int uv__open_cloexec(const char* path, int flags) { int uv__dup2_cloexec(int oldfd, int newfd) { int r; #if defined(__FreeBSD__) && __FreeBSD__ >= 10 - do - r = dup3(oldfd, newfd, O_CLOEXEC); - while (r == -1 && errno == EINTR); + r = dup3(oldfd, newfd, O_CLOEXEC); if (r == -1) return -errno; return r; #elif defined(__FreeBSD__) && defined(F_DUP2FD_CLOEXEC) - do - r = fcntl(oldfd, F_DUP2FD_CLOEXEC, newfd); - while (r == -1 && errno == EINTR); + r = fcntl(oldfd, F_DUP2FD_CLOEXEC, newfd); if (r != -1) return r; if (errno != EINVAL) @@ -996,7 +992,7 @@ int uv__dup2_cloexec(int oldfd, int newfd) { #if defined(__linux__) while (r == -1 && errno == EBUSY); #else - while (r == -1 && errno == EINTR); + while (0); /* Never retry. */ #endif if (r == -1)