7 int __dup3(int old, int new, int flags)
11 if (old==new) return __syscall_ret(-EINVAL);
13 while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY);
14 if (r!=-ENOSYS) return __syscall_ret(r);
15 if (flags & ~O_CLOEXEC) return __syscall_ret(-EINVAL);
17 while ((r=__syscall(SYS_dup2, old, new))==-EBUSY);
18 if (r >= 0 && (flags & O_CLOEXEC))
19 __syscall(SYS_fcntl, new, F_SETFD, FD_CLOEXEC);
21 while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY);
23 return __syscall_ret(r);
26 weak_alias(__dup3, dup3);