debugd: Prevent multiple instances of debugd from running.

DBus::Connection::request_name() does not indicate whether it
successfully acquires the requested DBus name or not. This CL changes
debugd to use newly introduced DBus::Connection::acquire_name()
(CL:195002) to ensure that debugd can successfully acquire its DBus

TEST=Tested the following:
1. `FEATURES=test emerge-$BOARD platform2`
2. Manually run the following commands in a root shell on the DUT:
   - `stop debugd` and then `start debugd` works
   - `restart debugd` works
   - `debugd` fails to acquire the DBus name when another instance of
     debugd is already running.

Change-Id: Ibe27a0ab2c49047b86411a4e62639c0f45a5b5cf
Reviewed-by: Jorge Lucangeli Obes <>
Reviewed-by: mukesh agrawal <>
Tested-by: Ben Chan <>
Commit-Queue: Ben Chan <>
diff --git a/src/ b/src/
index 7c72745..549cdfc 100644
--- a/src/
+++ b/src/
@@ -37,11 +37,8 @@
   storage_tool_ = new StorageTool();
   memory_tool_ = new MemtesterTool();
   wimax_status_tool_ = new WiMaxStatusTool();
-  try {
-    // TODO(ellyjones): Remove this when is fixed
-    dbus_->request_name(kDebugDaemonService);
-  }
-  catch (DBus::Error e) { // NOLINT
+  if (!dbus_->acquire_name(kDebugDaemonService)) {
+    LOG(ERROR) << "Failed to acquire D-Bus name " << kDebugDaemonService;
     return false;
   return true;