diff options
Diffstat (limited to 'usr/src/uts/common/syscall/fcntl.c')
-rw-r--r-- | usr/src/uts/common/syscall/fcntl.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/usr/src/uts/common/syscall/fcntl.c b/usr/src/uts/common/syscall/fcntl.c index 4a6e58f6b0..43a50d6d58 100644 --- a/usr/src/uts/common/syscall/fcntl.c +++ b/usr/src/uts/common/syscall/fcntl.c @@ -22,6 +22,7 @@ /* ONC_PLUS EXTRACT START */ /* * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -32,6 +33,7 @@ * under license from the Regents of the University of California. */ + /* ONC_PLUS EXTRACT END */ #include <sys/param.h> @@ -151,6 +153,7 @@ fcntl(int fdes, int cmd, intptr_t arg) /* ONC_PLUS EXTRACT END */ case F_DUPFD: + case F_DUPFD_CLOEXEC: p = curproc; if ((uint_t)iarg >= p->p_fno_ctl) { if (iarg >= 0) @@ -178,9 +181,21 @@ fcntl(int fdes, int cmd, intptr_t arg) fp->f_count--; mutex_exit(&fp->f_tlock); error = EMFILE; + } else { + if (cmd == F_DUPFD_CLOEXEC) { + f_setfd(retval, FD_CLOEXEC); + } } goto done; + case F_DUP2FD_CLOEXEC: + if (fdes == iarg) { + error = EINVAL; + goto done; + } + + /* lint -fallthrough */ + case F_DUP2FD: p = curproc; if (fdes == iarg) { @@ -208,6 +223,9 @@ fcntl(int fdes, int cmd, intptr_t arg) mutex_exit(&fp->f_tlock); releasef(fdes); if ((error = closeandsetf(iarg, fp)) == 0) { + if (cmd == F_DUP2FD_CLOEXEC) { + f_setfd(iarg, FD_CLOEXEC); + } retval = iarg; } else { mutex_enter(&fp->f_tlock); |