summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>2002-11-15 00:34:28 +0000
committerarchie <archie@FreeBSD.org>2002-11-15 00:34:28 +0000
commitd00c3df89eeb081d4e4fc0dc451472615dcd6fda (patch)
tree5257fa4ee9fba5465825a9d2080355f8a3253189 /lib
parent55125c47cfd21be472028fcb50f08488916539ca (diff)
downloadFreeBSD-src-d00c3df89eeb081d4e4fc0dc451472615dcd6fda.zip
FreeBSD-src-d00c3df89eeb081d4e4fc0dc451472615dcd6fda.tar.gz
When about to do an execve(), don't reset the O_NONBLOCK flag on any file
descriptors that have the close-on-exec flag set, as that will have no effect anyway and might screw something else up if the file descriptor happens to be shared with another process. PR: standards/43335 MFC after: 1 week
Diffstat (limited to 'lib')
-rw-r--r--lib/libc_r/uthread/uthread_execve.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/libc_r/uthread/uthread_execve.c b/lib/libc_r/uthread/uthread_execve.c
index 612f903..c0aa31c 100644
--- a/lib/libc_r/uthread/uthread_execve.c
+++ b/lib/libc_r/uthread/uthread_execve.c
@@ -69,6 +69,10 @@ _execve(const char *name, char *const * argv, char *const * envp)
/* Check if this file descriptor is in use: */
if (_thread_fd_table[i] != NULL &&
(_thread_fd_getflags(i) & O_NONBLOCK) == 0) {
+ /* Skip if the close-on-exec flag is set */
+ flags = __sys_fcntl(i, F_GETFD, NULL);
+ if ((flags & FD_CLOEXEC) != 0)
+ continue; /* don't bother, no point */
/* Get the current flags: */
flags = __sys_fcntl(i, F_GETFL, NULL);
/* Clear the nonblocking file descriptor flag: */
OpenPOWER on IntegriCloud