tools: Add SOCK_CLOEXEC to socket()
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Sun, 23 Oct 2011 12:16:30 +0000 (14:16 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 25 Oct 2011 11:36:42 +0000 (13:36 +0200)
Make sure all file descriptor are closed.

tools/alg-test.c
tools/iptables-test.c
tools/tap-test.c

index 7ab740e..48f0a56 100644 (file)
@@ -85,7 +85,7 @@ static int create_socket(void)
        };
        int sk, nsk;
 
-       sk = socket(PF_ALG, SOCK_SEQPACKET, 0);
+       sk = socket(PF_ALG, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
        if (sk < 0) {
                perror("Failed to create socket");
                return -1;
index 35c6300..133c4f9 100644 (file)
@@ -1159,7 +1159,7 @@ static struct connman_iptables *connman_iptables_init(const char *table_name)
        if (table->info == NULL)
                goto err;
 
-       table->ipt_sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
+       table->ipt_sock = socket(AF_INET, SOCK_RAW | SOCK_CLOEXEC, IPPROTO_RAW);
        if (table->ipt_sock < 0)
                goto err;
 
index 18fc00b..314d6bc 100644 (file)
@@ -43,7 +43,7 @@ static int inet_ifup(const char *ifname)
        struct ifreq ifr;
        int sk, err;
 
-       sk = socket(PF_INET, SOCK_DGRAM, 0);
+       sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
        if (sk < 0)
                return -errno;