Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: common/mac/launch_reporter.cc

Issue 571523004: Mac: Add support for in-process crash reporting (Closed) Base URL: https://chromium.googlesource.com/external/google-breakpad/src.git@master
Patch Set: Fixes for Mark Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« common/mac/launch_reporter.h ('K') | « common/mac/launch_reporter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/mac/launch_reporter.cc
diff --git a/client/mac/crash_generation/InspectorMain.mm b/common/mac/launch_reporter.cc
similarity index 59%
copy from client/mac/crash_generation/InspectorMain.mm
copy to common/mac/launch_reporter.cc
index 137c6a1e1bbf550012963705bd4a241fc68dd8be..e9856201bb5267e38b3d2b5890b8e8481245d38d 100644
--- a/client/mac/crash_generation/InspectorMain.mm
+++ b/common/mac/launch_reporter.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2007, Google Inc.
+// Copyright (c) 2014, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -26,40 +26,50 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Main driver for Inspector
-#import "client/mac/crash_generation/Inspector.h"
-#import <Cocoa/Cocoa.h>
+#include <cstdio>
Mark Mentovai 2014/09/15 13:38:44 <cstdio> only guarantees that you’ll have names in
Andre 2014/09/15 17:42:39 Done.
+#include <sys/wait.h>
+#include <unistd.h>
namespace google_breakpad {
-//=============================================================================
-extern "C" {
-
-int main(int argc, char *const argv[]) {
-#if DEBUG
- // Since we're launched on-demand, this is necessary to see debugging
- // output in the console window.
- freopen("/dev/console", "w", stdout);
- freopen("/dev/console", "w", stderr);
-#endif
+void LaunchReporter(const char *reporterExecutablePath,
+ const char *configFilePath) {
+ const char* argv[] = { reporterExecutablePath, configFilePath, NULL };
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ // Launch the reporter
+ pid_t pid = fork();
- if (argc != 2) {
- exit(0);
+ // 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);
+ fprintf(stderr, "Failed to launch reporter process\n");
Mark Mentovai 2014/09/15 13:38:44 Gimme a strerror(errno) or a perror("exec"), and m
Andre 2014/09/15 17:42:39 Done.
+ unlink(configFilePath); // launch failed - get rid of config file
+ _exit(1);
}
- // Our first command-line argument contains the name of the service
- // that we're providing.
- google_breakpad::Inspector inspector;
- inspector.Inspect(argv[1]);
- [pool release];
+ // Wait until the Reporter child process exits.
Mark Mentovai 2014/09/15 13:38:44 fork() may have returned -1 indicating failure. In
Andre 2014/09/15 17:42:39 Done.
+ //
- return 0;
-}
+ // We'll use a timeout of one minute.
+ int timeoutCount = 60; // 60 seconds
-} // extern "C"
+ 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
« common/mac/launch_reporter.h ('K') | « common/mac/launch_reporter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698