From: Rich Felker Date: Thu, 21 Apr 2011 01:05:10 +0000 (-0400) Subject: workaround bug in linux dup2 X-Git-Tag: v0.7.9~8 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f9a6372a98cc4d1b70400b2e7238e1f9eae50558;p=oweals%2Fmusl.git workaround bug in linux dup2 the linux documentation for dup2 says it can fail with EBUSY due to a race condition with open and dup in the kernel. shield applications (and the rest of libc) from this nonsense by looping until it succeeds --- diff --git a/src/unistd/dup2.c b/src/unistd/dup2.c index 7945f853..87a0d445 100644 --- a/src/unistd/dup2.c +++ b/src/unistd/dup2.c @@ -1,7 +1,10 @@ #include +#include #include "syscall.h" int dup2(int old, int new) { - return syscall(SYS_dup2, old, new); + int r; + while ((r=__syscall(SYS_dup2, old, new))==-EBUSY); + return __syscall_ret(r); }