X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Funistd%2Fdup3.c;h=40798bdeed12ea6984198f859e700395b01042f5;hb=3281047cfca0f3848d0613e3c0d19d41b0531564;hp=1e7dc3e73a6fd7b10f17c7a8cc6dd0396f3d0d4d;hpb=c99b7daafdbf1e2415bf408e67ca7813e7ddeedf;p=musl diff --git a/src/unistd/dup3.c b/src/unistd/dup3.c index 1e7dc3e7..40798bde 100644 --- a/src/unistd/dup3.c +++ b/src/unistd/dup3.c @@ -15,7 +15,8 @@ int __dup3(int old, int new, int flags) 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); + if (r >= 0 && (flags & O_CLOEXEC)) + __syscall(SYS_fcntl, new, F_SETFD, FD_CLOEXEC); #else while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY); #endif