aboutsummaryrefslogtreecommitdiff
path: root/src/client/mac/crash_generation/Inspector.mm
diff options
context:
space:
mode:
authorandresantoso@chromium.org <andresantoso@chromium.org>2014-09-15 22:48:18 +0000
committerandresantoso@chromium.org <andresantoso@chromium.org>2014-09-15 22:48:18 +0000
commitdef0b7a7b0c4ad3c2f27ddddffcbba7892594da6 (patch)
treeb7af14b1b86942c590c0ae074eda01e72a404e4c /src/client/mac/crash_generation/Inspector.mm
parentThis CL initialize NSData in HTTPMultipartUpload.m to nil. (diff)
downloadbreakpad-def0b7a7b0c4ad3c2f27ddddffcbba7892594da6.tar.xz
Mac: Add support for in-process crash reporting to Breakpad.
Add new option BREAKPAD_IN_PROCESS. If YES, Breakpad will write the dump file in-process and then launch the reporter executable as a child process. Originally reviewed at https://codereview.chromium.org/571523004/ BUG=chromium:414239 R=mark@chromium.org Review URL: https://breakpad.appspot.com/1714002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1375 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/mac/crash_generation/Inspector.mm')
-rw-r--r--src/client/mac/crash_generation/Inspector.mm51
1 files changed, 4 insertions, 47 deletions
diff --git a/src/client/mac/crash_generation/Inspector.mm b/src/client/mac/crash_generation/Inspector.mm
index d226ca38..dc6f4808 100644
--- a/src/client/mac/crash_generation/Inspector.mm
+++ b/src/client/mac/crash_generation/Inspector.mm
@@ -43,6 +43,7 @@
#import "common/mac/MachIPC.h"
#include "common/mac/bootstrap_compat.h"
+#include "common/mac/launch_reporter.h"
#import "GTMDefines.h"
@@ -76,7 +77,9 @@ void Inspector::Inspect(const char *receive_port_name) {
if (wrote_minidump) {
// Ask the user if he wants to upload the crash report to a server,
// and do so if he agrees.
- LaunchReporter(config_file_.GetFilePath());
+ LaunchReporter(
+ config_params_.GetValueForKey(BREAKPAD_REPORTER_EXE_LOCATION),
+ config_file_.GetFilePath());
} else {
fprintf(stderr, "Inspection of crashed process failed\n");
}
@@ -355,51 +358,5 @@ kern_return_t Inspector::SendAcknowledgement() {
return KERN_INVALID_NAME;
}
-//=============================================================================
-void Inspector::LaunchReporter(const char *inConfigFilePath) {
- // Extract the path to the reporter executable.
- const char *reporterExecutablePath =
- config_params_.GetValueForKey(BREAKPAD_REPORTER_EXE_LOCATION);
-
- // Setup and launch the crash dump sender.
- const char *argv[3];
- argv[0] = reporterExecutablePath;
- argv[1] = inConfigFilePath;
- argv[2] = NULL;
-
- // Launch the reporter
- pid_t pid = fork();
-
- // If we're in the child, load in our new executable and run.
- // The parent will not wait for the child to complete.
- if (pid == 0) {
- execv(argv[0], (char * const *)argv);
- config_file_.Unlink(); // launch failed - get rid of config file
- _exit(1);
- }
-
- // Wait until the Reporter child process exits.
- //
-
- // We'll use a timeout of one minute.
- int timeoutCount = 60; // 60 seconds
-
- while (timeoutCount-- > 0) {
- int status;
- pid_t result = waitpid(pid, &status, WNOHANG);
-
- if (result == 0) {
- // The child has not yet finished.
- sleep(1);
- } else if (result == -1) {
- // error occurred.
- break;
- } else {
- // child has finished
- break;
- }
- }
-}
-
} // namespace google_breakpad