Add O_CLOEXEC to lots of open() calls.

and other related fixups.

Change-Id: Ia88fb37a07ff6777d00c49800081f5a519c0c78d
diff --git a/init/watchdogd.c b/init/watchdogd.c
index 7f64fc4..0790811 100644
--- a/init/watchdogd.c
+++ b/init/watchdogd.c
@@ -48,7 +48,7 @@
 
     timeout = interval + margin;
 
-    fd = open(DEV_NAME, O_RDWR);
+    fd = open(DEV_NAME, O_RDWR|O_CLOEXEC);
     if (fd < 0) {
         ERROR("watchdogd: Failed to open %s: %s\n", DEV_NAME, strerror(errno));
         return 1;