Print this page
3665 Implement O_CLOEXEC as an open() flag
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Gordon Ross <gwr@nexenta.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
@@ -25,10 +25,13 @@
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
+ * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
+ */
+/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
#include <sys/param.h>
@@ -224,10 +227,13 @@
/*
* We must now fill in the slot
* falloc reserved.
*/
setf(fd, fp);
+ if ((filemode & FCLOEXEC) != 0) {
+ f_setfd(fd, FD_CLOEXEC);
+ }
return (fd);
} else {
/*
* Special handling for /dev/fd.
* Give up the file pointer
@@ -250,10 +256,13 @@
}
mutex_enter(&fp->f_tlock);
fp->f_count++;
mutex_exit(&fp->f_tlock);
setf(fd, fp);
+ if ((filemode & FCLOEXEC) != 0) {
+ f_setfd(fd, FD_CLOEXEC);
+ }
releasef(dupfd);
}
return (fd);
} else {
setf(fd, NULL);