linux: don't retry dup2/dup3 on EINTR
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é <saghul@gmail.com>
This commit is contained in:
parent
4052c74797
commit
af7a3614d0
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user