projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
10d7561
)
workaround bug in linux dup2
author
Rich Felker
<dalias@aerifal.cx>
Thu, 21 Apr 2011 01:05:10 +0000
(21:05 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Thu, 21 Apr 2011 01:05:10 +0000
(21:05 -0400)
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
src/unistd/dup2.c
patch
|
blob
|
history
diff --git
a/src/unistd/dup2.c
b/src/unistd/dup2.c
index 7945f853cae600b317ebab09306c4a8df1d06aa4..87a0d44538eb49162bf4d26824b0d35de19af0fb 100644
(file)
--- a/
src/unistd/dup2.c
+++ b/
src/unistd/dup2.c
@@
-1,7
+1,10
@@
#include <unistd.h>
+#include <errno.h>
#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);
}