Diff between 71d6558c19b647e30411d488b3983b4f9f67e149 and 2290fbb9f5f0d1aa5b4f2b5529d0427af0bf3479

Changed Files

File Additions Deletions Status
monitor/btsnoop.c +2 -2 modified
monitor/control.c +2 -2 modified
monitor/hcidump.c +2 -2 modified

Full Patch

diff --git a/monitor/btsnoop.c b/monitor/btsnoop.c
index 0b3e412..147e9ee 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 93189fd..49df440 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 373d2f5..4eb0a49 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;