summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Qiu <zqiu@google.com>2015-09-27 22:04:52 -0700
committerPeter Qiu <zqiu@google.com>2015-09-27 22:04:52 -0700
commit9b1df04c163524658b482602c2070aacddbe7374 (patch)
tree270c20ed64855db245183f5eef5ffe9fe78cd4ba
parentfc98057995ef9c9cc8dda720aa7e0e30d1b34d8e (diff)
downloadapmanager-9b1df04c163524658b482602c2070aacddbe7374.tar.gz
Do not daemonize (fork) the daemon process
When starting the daemon using an init system, the environment setup is already being handled by the init system, so there is no need to daemonize the daemon process create such setup. By daemonizing the daemon process, it spawns off a new process to run the daemon and terminates the current process. This causes a problem with the init system, where it thinks that the daemon failed to start. We were able to work around it on Chrome OS's upstart script by adding the forking expectation in the init scritp ("expect fork"), but there is not such workaround on Android's init system. Fix it by removing the daemonize call (daemon()) and remove the the forking expectation on Chrome OS's init script. Bug: 24412675 TEST=Manual test on dragonboard TEST=start/stop apmanager on Chrome OS device Change-Id: I4dff678946801310982c3af366ab6182f5864a81
-rw-r--r--init/apmanager.conf1
-rw-r--r--main.cc4
2 files changed, 0 insertions, 5 deletions
diff --git a/init/apmanager.conf b/init/apmanager.conf
index d992615..17052d2 100644
--- a/init/apmanager.conf
+++ b/init/apmanager.conf
@@ -19,7 +19,6 @@ author "chromium-os-dev@chromium.org"
start on stopped iptables and stopped ip6tables and started shill
stop on stopping system-services
-expect fork
env APMANAGER_LOG_LEVEL=0
diff --git a/main.cc b/main.cc
index f0ee801..85222af 100644
--- a/main.cc
+++ b/main.cc
@@ -129,10 +129,6 @@ int main(int argc, char* argv[]) {
return 0;
}
- const int nochdir = 0, noclose = 0;
- if (!cl->HasSwitch(switches::kForeground))
- PLOG_IF(FATAL, daemon(nochdir, noclose) == -1) << "Failed to daemonize";
-
apmanager::Daemon daemon(base::Bind(&OnStartup, argv[0], cl));
daemon.Run();