diff options
author | markj <markj@FreeBSD.org> | 2017-09-12 13:47:54 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2017-09-12 13:47:54 +0000 |
commit | 7b7b799a85d865b64f43fc1758d507dc8af808a9 (patch) | |
tree | e61b6aae9041ca4c4f59976d76c7e30e629b25a1 /cddl/contrib/opensolaris/lib | |
parent | 7c49d67c7953d7ac501e346e877df4331d202a3a (diff) | |
download | FreeBSD-src-7b7b799a85d865b64f43fc1758d507dc8af808a9.zip FreeBSD-src-7b7b799a85d865b64f43fc1758d507dc8af808a9.tar.gz |
MFC r323166:
Use O_CLOEXEC when opening persistent handles in libdtrace.
Diffstat (limited to 'cddl/contrib/opensolaris/lib')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c | 9 |
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 653f2b2..90b1d6b57 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c @@ -965,7 +965,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) || @@ -1102,7 +1102,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__) /* @@ -1118,7 +1118,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 */ @@ -1148,9 +1148,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); |