From af7a3614d0d64233bae84fe089faefbcf720e95b Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 5 Nov 2015 16:49:38 +0100 Subject: [PATCH] linux: don't retry dup2/dup3 on EINTR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Retrying seems like a bad idea in a multi-threaded program because the man page leaves it unspecified whether the file descriptor is closed after EINTR. It's probably an academic issue because as far as I have been able to establish by checking the kernel sources, dup2 and dup3 never actually return EINTR. For dup3, this appears to have been the case since its introduction in v2.6.27; for dup2, it goes back to at least v2.6.18. 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/core.c b/src/unix/core.c index 0db5f828..efbb85d4 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -980,7 +980,7 @@ int uv__dup2_cloexec(int oldfd, int newfd) { if (!no_dup3) { do r = uv__dup3(oldfd, newfd, UV__O_CLOEXEC); - while (r == -1 && (errno == EINTR || errno == EBUSY)); + while (r == -1 && errno == EBUSY); if (r != -1) return r; if (errno != ENOSYS) @@ -994,7 +994,7 @@ int uv__dup2_cloexec(int oldfd, int newfd) { do r = dup2(oldfd, newfd); #if defined(__linux__) - while (r == -1 && (errno == EINTR || errno == EBUSY)); + while (r == -1 && errno == EBUSY); #else while (r == -1 && errno == EINTR); #endif