X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Funistd%2Fdup3.c;h=1e7dc3e73a6fd7b10f17c7a8cc6dd0396f3d0d4d;hb=c99b7daafdbf1e2415bf408e67ca7813e7ddeedf;hp=f919f79125a624c4d47c1cb50a103f82e0ba576f;hpb=fb7fb5e4bd7ccb8efa691364404efc7804fad90c;p=musl diff --git a/src/unistd/dup3.c b/src/unistd/dup3.c index f919f791..1e7dc3e7 100644 --- a/src/unistd/dup3.c +++ b/src/unistd/dup3.c @@ -9,9 +9,10 @@ int __dup3(int old, int new, int flags) int r; #ifdef SYS_dup2 if (old==new) return __syscall_ret(-EINVAL); - if (flags & O_CLOEXEC) { + if (flags) { while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY); if (r!=-ENOSYS) return __syscall_ret(r); + if (flags & ~O_CLOEXEC) return __syscall_ret(-EINVAL); } while ((r=__syscall(SYS_dup2, old, new))==-EBUSY); if (flags & O_CLOEXEC) __syscall(SYS_fcntl, new, F_SETFD, FD_CLOEXEC);