aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2017-09-05 00:11:06 +0000
committerMark Johnston <markj@FreeBSD.org>2017-09-05 00:11:06 +0000
commitafd2f355fb5524b1a7e53c28523d0581a50c2380 (patch)
tree77924dcd522cd1cc25c083a5be73a3152d924c74 /cddl/contrib/opensolaris
parent93cf995aef0e785adede69f40b2c59c04126c2dc (diff)
downloadsrc-afd2f355fb5524b1a7e53c28523d0581a50c2380.tar.gz
src-afd2f355fb5524b1a7e53c28523d0581a50c2380.zip
Use O_CLOEXEC when opening persistent handles in libdtrace.
PR: 199810 Submitted by: jau@iki.fi MFC after: 1 week
Notes
Notes: svn path=/head/; revision=323166
Diffstat (limited to 'cddl/contrib/opensolaris')
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
index 3a8061ed94d0..92d3382296fc 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
@@ -963,7 +963,7 @@ dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *dfp)
(void) snprintf(path, sizeof (path), "/dev/dtrace/%s", p1);
- if ((fd = open(path, O_RDONLY)) == -1)
+ if ((fd = open(path, O_RDONLY | O_CLOEXEC)) == -1)
continue; /* failed to open driver; just skip it */
if (((prov = malloc(sizeof (dt_provmod_t))) == NULL) ||
@@ -1100,7 +1100,7 @@ dt_vopen(int version, int flags, int *errp,
*/
dt_provmod_open(&provmod, &df);
- dtfd = open("/dev/dtrace/dtrace", O_RDWR);
+ dtfd = open("/dev/dtrace/dtrace", O_RDWR | O_CLOEXEC);
err = errno; /* save errno from opening dtfd */
#if defined(__FreeBSD__)
/*
@@ -1116,7 +1116,7 @@ dt_vopen(int version, int flags, int *errp,
#ifdef illumos
ftfd = open("/dev/dtrace/provider/fasttrap", O_RDWR);
#else
- ftfd = open("/dev/dtrace/fasttrap", O_RDWR);
+ ftfd = open("/dev/dtrace/fasttrap", O_RDWR | O_CLOEXEC);
#endif
fterr = ftfd == -1 ? errno : 0; /* save errno from open ftfd */
@@ -1146,9 +1146,6 @@ dt_vopen(int version, int flags, int *errp,
return (set_open_errno(dtp, errp, err));
}
- (void) fcntl(dtfd, F_SETFD, FD_CLOEXEC);
- (void) fcntl(ftfd, F_SETFD, FD_CLOEXEC);
-
alloc:
if ((dtp = malloc(sizeof (dtrace_hdl_t))) == NULL) {
dt_provmod_destroy(&provmod);