projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dup3: don't set FD_CLOEXEC on failure on kernels without dup3 syscall
[musl]
/
src
/
unistd
/
dup3.c
diff --git
a/src/unistd/dup3.c
b/src/unistd/dup3.c
index
1e7dc3e
..
40798bd
100644
(file)
--- 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) 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
#else
while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY);
#endif