DO NOT MERGE Fix potential DoS caused by delivering signal to BT process

FPIIM-1270
FPIIM-1268

Bug: 28885210
Change-Id: I63866d894bfca47464d6e42e3fb0357c4f94d360
diff --git a/tools/hci/main.c b/tools/hci/main.c
index fc433bc..97fbef1 100644
--- a/tools/hci/main.c
+++ b/tools/hci/main.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <hardware/bluetooth.h>
 #include <netinet/in.h>
 #include <stdio.h>
@@ -149,16 +150,16 @@
   addr.sin_family = AF_INET;
   addr.sin_addr.s_addr = htonl(0x7F000001);
   addr.sin_port = htons(8873);
-  if (connect(sock, (const struct sockaddr *)&addr, sizeof(addr)) == -1)
+  if (TEMP_FAILURE_RETRY(connect(sock, (const struct sockaddr *)&addr, sizeof(addr))) == -1)
     goto error;
 
-  if (send(sock, &type, 1, 0) != 1)
+  if (TEMP_FAILURE_RETRY(send(sock, &type, 1, 0)) != 1)
     goto error;
 
-  if (send(sock, &length, 2, 0) != 2)
+  if (TEMP_FAILURE_RETRY(send(sock, &length, 2, 0)) != 2)
     goto error;
 
-  if (send(sock, packet, length, 0) != (ssize_t)length)
+  if (TEMP_FAILURE_RETRY(send(sock, packet, length, 0)) != (ssize_t)length)
     goto error;
 
   close(sock);