svn commit: r298112 - head/usr.bin/script
Baptiste Daroussin
bapt at FreeBSD.org
Sat Apr 16 12:47:25 UTC 2016
Author: bapt
Date: Sat Apr 16 12:47:23 2016
New Revision: 298112
URL: https://svnweb.freebsd.org/changeset/base/298112
Log:
Directly set the O_CLOEXEC flags via the open(2) attributes
MFC after: 1 week
Modified:
head/usr.bin/script/script.c
Modified: head/usr.bin/script/script.c
==============================================================================
--- head/usr.bin/script/script.c Sat Apr 16 12:42:01 2016 (r298111)
+++ head/usr.bin/script/script.c Sat Apr 16 12:47:23 2016 (r298112)
@@ -161,17 +161,14 @@ main(int argc, char *argv[])
asprintf(&fmfname, "%s.filemon", fname);
if (!fmfname)
err(1, "%s.filemon", fname);
- if ((fm_fd = open("/dev/filemon", O_RDWR)) == -1)
+ if ((fm_fd = open("/dev/filemon", O_RDWR | O_CLOEXEC)) == -1)
err(1, "open(\"/dev/filemon\", O_RDWR)");
- if ((fm_log = open(fmfname, O_WRONLY | O_CREAT | O_TRUNC,
+ if ((fm_log = open(fmfname,
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1)
err(1, "open(%s)", fmfname);
if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) < 0)
err(1, "Cannot set filemon log file descriptor");
-
- /* Set up these two fd's to close on exec. */
- (void)fcntl(fm_fd, F_SETFD, FD_CLOEXEC);
- (void)fcntl(fm_log, F_SETFD, FD_CLOEXEC);
}
if (pflg)
More information about the svn-src-head
mailing list