mirror of
https://github.com/fluencelabs/musl
synced 2025-05-30 16:11:40 +00:00
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
11 lines
178 B
C
11 lines
178 B
C
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include "syscall.h"
|
|
|
|
int dup2(int old, int new)
|
|
{
|
|
int r;
|
|
while ((r=__syscall(SYS_dup2, old, new))==-EBUSY);
|
|
return __syscall_ret(r);
|
|
}
|