summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2011-10-23 12:16:23 (GMT)
committerMarcel Holtmann <marcel@holtmann.org>2011-10-25 11:34:06 (GMT)
commit4826f90b555f009972276be1fa945d81b435950a (patch)
tree2d62eda201ef154be4aeb869978685e9d99f1a24 /tools
parentcb3e78500a2539a61d73ecb9708a2b06ea1f356d (diff)
downloadconnman-4826f90b555f009972276be1fa945d81b435950a.zip
connman-4826f90b555f009972276be1fa945d81b435950a.tar.gz
connman-4826f90b555f009972276be1fa945d81b435950a.tar.bz2
tools: Add O_CLOEXEC to open()
Make sure all file descriptor are closed.
Diffstat (limited to 'tools')
-rw-r--r--tools/alg-test.c2
-rw-r--r--tools/stats-tool.c3
-rw-r--r--tools/tap-test.c2
-rw-r--r--tools/wispr.c2
4 files changed, 5 insertions, 4 deletions
diff --git a/tools/alg-test.c b/tools/alg-test.c
index 33c3975..7ab740e 100644
--- a/tools/alg-test.c
+++ b/tools/alg-test.c
@@ -60,7 +60,7 @@ static int create_hash(int sk, const char *pathname)
struct stat st;
int fd;
- fd = open(pathname, O_RDONLY);
+ fd = open(pathname, O_RDONLY | O_CLOEXEC);
if (fd < 0)
return -1;
diff --git a/tools/stats-tool.c b/tools/stats-tool.c
index cd48806..0f06d8e 100644
--- a/tools/stats-tool.c
+++ b/tools/stats-tool.c
@@ -470,7 +470,8 @@ static int stats_open(struct stats_file *file, const char *name)
if (name != NULL) {
file->name = g_strdup(name);
- file->fd = TFR(open(file->name, O_RDWR | O_CREAT, 0644));
+ file->fd = TFR(open(file->name,
+ O_RDWR | O_CREAT | O_CLOEXEC, 0644));
if (file->fd == -1) {
fprintf(stderr, "open error %s for %s\n",
strerror(errno), file->name);
diff --git a/tools/tap-test.c b/tools/tap-test.c
index c215945..18fc00b 100644
--- a/tools/tap-test.c
+++ b/tools/tap-test.c
@@ -80,7 +80,7 @@ static int create_tap(const char *ifname)
struct ifreq ifr;
int fd, val;
- fd = open("/dev/net/tun", O_RDWR);
+ fd = open("/dev/net/tun", O_RDWR | O_CLOEXEC);
if (fd < 0) {
perror("Failed to open TUN/TAP device");
return -1;
diff --git a/tools/wispr.c b/tools/wispr.c
index 0792f5b..1300e40 100644
--- a/tools/wispr.c
+++ b/tools/wispr.c
@@ -373,7 +373,7 @@ static gboolean user_input(const char *label, gboolean hidden,
data->user_data = user_data;
data->hidden = hidden;
- data->fd = open("/dev/tty", O_RDWR | O_NOCTTY);
+ data->fd = open("/dev/tty", O_RDWR | O_NOCTTY | O_CLOEXEC);
if (data->fd < 0)
goto error;