Date: Sat, 23 Apr 2016 10:10:29 +0000 (UTC) From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r298510 - stable/10/usr.bin/script Message-ID: <201604231010.u3NAATcj017615@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bapt Date: Sat Apr 23 10:10:29 2016 New Revision: 298510 URL: https://svnweb.freebsd.org/changeset/base/298510 Log: MFC: 298112 Directly set the O_CLOEXEC flags via the open(2) attributes Sponsored by: Essen Hackathon Modified: stable/10/usr.bin/script/script.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/script/script.c ============================================================================== --- stable/10/usr.bin/script/script.c Sat Apr 23 10:06:57 2016 (r298509) +++ stable/10/usr.bin/script/script.c Sat Apr 23 10:10:29 2016 (r298510) @@ -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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604231010.u3NAATcj017615>