Module Name:    src
Committed By:   sjg
Date:           Fri Jul 10 15:53:30 UTC 2020

Modified Files:
        src/usr.bin/make/filemon: filemon_dev.c

Log Message:
Use O_CLOEXEC and save a syscall.

Reviewed by: riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/filemon/filemon_dev.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/filemon/filemon_dev.c
diff -u src/usr.bin/make/filemon/filemon_dev.c:1.2 src/usr.bin/make/filemon/filemon_dev.c:1.3
--- src/usr.bin/make/filemon/filemon_dev.c:1.2	Fri Jul 10 00:42:53 2020
+++ src/usr.bin/make/filemon/filemon_dev.c	Fri Jul 10 15:53:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: filemon_dev.c,v 1.2 2020/07/10 00:42:53 sjg Exp $	*/
+/*	$NetBSD: filemon_dev.c,v 1.3 2020/07/10 15:53:30 sjg Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -70,13 +70,12 @@ filemon_open(void)
 		return NULL;
 
 	/* Try opening /dev/filemon, up to six times (cargo cult!).  */
-	for (i = 0; (F->fd = open(_PATH_FILEMON, O_RDWR)) == -1; i++) {
+	for (i = 0; (F->fd = open(_PATH_FILEMON, O_RDWR|O_CLOEXEC)) == -1; i++) {
 		if (i == 5) {
 			error = errno;
 			goto fail0;
 		}
 	}
-	(void)fcntl(F->fd, F_SETFD, FD_CLOEXEC);
 
 	/* Success!  */
 	return F;

Reply via email to