8 int __dup3(int old, int new, int flags)
12 if (old==new) return __syscall_ret(-EINVAL);
13 if (flags & O_CLOEXEC) {
14 while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY);
15 if (r!=-ENOSYS) return __syscall_ret(r);
17 while ((r=__syscall(SYS_dup2, old, new))==-EBUSY);
18 if (flags & O_CLOEXEC) __syscall(SYS_fcntl, new, F_SETFD, FD_CLOEXEC);
20 while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY);
22 return __syscall_ret(r);
25 weak_alias(__dup3, dup3);