diff options
author | bapt <bapt@FreeBSD.org> | 2016-04-23 10:10:29 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2016-04-23 10:10:29 +0000 |
commit | 055dc85d60fa4be6e2d24ddde3d3b57c76d63d17 (patch) | |
tree | 7c766548b22ffedd1c0061e4ec8e780d66750b81 | |
parent | 7b928e00e50c3740576acc6c6e252aed5429a5cb (diff) | |
download | FreeBSD-src-055dc85d60fa4be6e2d24ddde3d3b57c76d63d17.zip FreeBSD-src-055dc85d60fa4be6e2d24ddde3d3b57c76d63d17.tar.gz |
MFC: 298112
Directly set the O_CLOEXEC flags via the open(2) attributes
Sponsored by: Essen Hackathon
-rw-r--r-- | usr.bin/script/script.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c index 82a9b2e..24ee4b0 100644 --- a/usr.bin/script/script.c +++ b/usr.bin/script/script.c @@ -158,17 +158,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) |