From 2290fbb9f5f0d1aa5b4f2b5529d0427af0bf3479 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 4 Nov 2012 06:22:26 +0100 Subject: [PATCH] monitor: Use SOCK_CLOEXEC and O_CLOEXEC --- monitor/btsnoop.c | 4 ++-- monitor/control.c | 4 ++-- monitor/hcidump.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/monitor/btsnoop.c b/monitor/btsnoop.c index 0b3e4125a..147e9ee46 100644 --- a/monitor/btsnoop.c +++ b/monitor/btsnoop.c @@ -85,7 +85,7 @@ void btsnoop_create(const char *path) if (btsnoop_fd >= 0) return; - btsnoop_fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, + btsnoop_fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (btsnoop_fd < 0) return; @@ -168,7 +168,7 @@ int btsnoop_open(const char *path) return -1; } - btsnoop_fd = open(path, O_RDONLY); + btsnoop_fd = open(path, O_RDONLY | O_CLOEXEC); if (btsnoop_fd < 0) { perror("Failed to open file"); return -1; diff --git a/monitor/control.c b/monitor/control.c index 93189fd1d..49df44012 100644 --- a/monitor/control.c +++ b/monitor/control.c @@ -601,7 +601,7 @@ static int open_socket(uint16_t channel) struct sockaddr_hci addr; int fd, opt = 1; - fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); + fd = socket(AF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC, BTPROTO_HCI); if (fd < 0) { perror("Failed to open channel"); return -1; @@ -739,7 +739,7 @@ void control_server(const char *path) unlink(path); - fd = socket(PF_UNIX, SOCK_STREAM, 0); + fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); if (fd < 0) { perror("Failed to open server socket"); return; diff --git a/monitor/hcidump.c b/monitor/hcidump.c index 373d2f55f..4eb0a4939 100644 --- a/monitor/hcidump.c +++ b/monitor/hcidump.c @@ -62,7 +62,7 @@ static int open_hci_dev(uint16_t index) struct hci_filter flt; int fd, opt = 1; - fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); + fd = socket(AF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC, BTPROTO_HCI); if (fd < 0) { perror("Failed to open channel"); return -1; @@ -263,7 +263,7 @@ static int open_stack_internal(void) struct hci_filter flt; int fd, opt = 1; - fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); + fd = socket(AF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC, BTPROTO_HCI); if (fd < 0) { perror("Failed to open channel"); return -1; -- 2.47.3