Merge "init/service.cpp: fix FD leak for services with consoles" am: 4173d9b57c am: 869ce5d40a
am: 9bebb6f3a3

Change-Id: Id9c363a2fc3519c2c821be8b7e5511150f85dd26
diff --git a/init/service.cpp b/init/service.cpp
index a7eaf66..e967a7c 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -567,9 +567,9 @@
             console_ = default_console;
         }
 
-        bool have_console = (open(console_.c_str(), O_RDWR | O_CLOEXEC) != -1);
+        bool have_console = (access(console_.c_str(), R_OK | W_OK) != -1);
         if (!have_console) {
-            PLOG(ERROR) << "service '" << name_ << "' couldn't open console '" << console_ << "'";
+            PLOG(ERROR) << "service '" << name_ << "' cannot gain read/write access to console '" << console_ << "'";
             flags_ |= SVC_DISABLED;
             return false;
         }