Date: Tue, 12 Sep 2017 13:47:54 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r323495 - stable/11/cddl/contrib/opensolaris/lib/libdtrace/common Message-ID: <201709121347.v8CDlsjb041110@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Tue Sep 12 13:47:54 2017 New Revision: 323495 URL: https://svnweb.freebsd.org/changeset/base/323495 Log: MFC r323166: Use O_CLOEXEC when opening persistent handles in libdtrace. Modified: stable/11/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Tue Sep 12 13:45:04 2017 (r323494) +++ stable/11/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Tue Sep 12 13:47:54 2017 (r323495) @@ -965,7 +965,7 @@ dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *d (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 */ @@ -1147,9 +1147,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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709121347.v8CDlsjb041110>