summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2014-11-08 22:08:02 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2014-11-08 22:08:02 +0000
commitb3090d5e34cff89fbf108e8ca7b4e2a49f887a51 (patch)
tree448721be0bef82b9366cdbba5cbf560c9774dc9f
parent2dd94a60e2bdd35c174213dacd00f9a3d352a4d2 (diff)
Use open(O_CLOEXEC) rather than open() + fcntl(FD_CLOEXEC). Inspired
by and ok guenther@.
-rw-r--r--sbin/dhclient/bpf.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index 3cc033680a0..6ffdfd369dd 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.34 2014/11/08 19:30:30 krw Exp $ */
+/* $OpenBSD: bpf.c,v 1.35 2014/11/08 22:08:01 krw Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -66,7 +66,7 @@ if_register_bpf(void)
/* Open a BPF device */
for (b = 0; 1; b++) {
snprintf(filename, sizeof(filename), BPF_FORMAT, b);
- sock = open(filename, O_RDWR, 0);
+ sock = open(filename, O_RDWR | O_CLOEXEC, 0);
if (sock < 0) {
if (errno == EBUSY)
continue;
@@ -195,7 +195,6 @@ if_register_receive(void)
/* Open a BPF device and hang it on this interface. */
ifi->rfdesc = if_register_bpf();
- fcntl(ifi->rfdesc, F_SETFD, FD_CLOEXEC);
/* Make sure the BPF version is in range. */
if (ioctl(ifi->rfdesc, BIOCVERSION, &v) < 0)