crash-reporter: avoid deadlock if dbus-daemon is hanging
Change-Id: I40ba7fb556217bf0bea156e0496145d7195a1229
BUG=7783
TEST=sudo pkill -STOP dbus-daemon;sleep 100&ill -SEGV $!;pgrep crash_reporter shows crash_reporter finished dumping sleep, even though dbus-daemon is unreachable. Also ran UserCrash and CrashSender.
Review URL: http://codereview.chromium.org/3976001
diff --git a/crash_reporter/crash_reporter.cc b/crash_reporter/crash_reporter.cc
index d858386..2f8e987 100644
--- a/crash_reporter/crash_reporter.cc
+++ b/crash_reporter/crash_reporter.cc
@@ -67,7 +67,7 @@
kCrashKindUser,
kCrashKindMax);
std::string command = StringPrintf(
- "/usr/bin/dbus-send --type=signal --system / \"%s\"",
+ "/usr/bin/dbus-send --type=signal --system / \"%s\" &",
kUserCrashSignal);
// Announce through D-Bus whenever a user crash happens. This is
// used by the metrics daemon to log active use time between
@@ -77,8 +77,18 @@
// using a dbus library directly. However, this should run
// relatively rarely and longer term we may need to implement a
// better way to do this that doesn't rely on D-Bus.
+ //
+ // We run in the background in case dbus daemon itself is crashed
+ // and not responding. This allows us to not block and potentially
+ // deadlock on a dbus-daemon crash. If dbus-daemon crashes without
+ // restarting, each crash will fork off a lot of dbus-send
+ // processes. Such a system is in a unusable state and will need
+ // to be restarted anyway.
- int status __attribute__((unused)) = system(command.c_str());
+ int status = system(command.c_str());
+ if (status != 0) {
+ s_system_log.LogWarning("dbus-send running failed");
+ }
}
static int Initialize(KernelCollector *kernel_collector,