aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@google.com>2017-07-26 18:30:57 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-26 18:31:12 +0000
commit737149126df1a44bc80393cfe35017bab983c357 (patch)
treeeef365c4d836513532228f7f2bf3b154d3d02e7c /tools
parent1a2a7abe96d258399cca111ea55594599b461c33 (diff)
Revert "ok, exit() child processes instead of _exit()"
This reverts commit 9ac801c12c48b67b48e5a8ef2876a093b7de73fc. Reason for revert: breaks threaded mode. Original change's description: > ok, exit() child processes instead of _exit() > > We want the atexit() hook to print deferred logs (crash dumps, etc.) only when the main, parent process exits. Ending the child processes with _exit() instead of exit() avoids calling atexit() hooks, but also global destructors. This is more complex than we need: we can just print before main() exits. Only the main, parent process gets there. > > This now runs each child process' global destructors, which makes trace.json "work": we get a trace of whichever child process finishes last. It's a start. > > Change-Id: I0cc2b12592f0f79e73a43a160b9fd06dba1fee25 > Reviewed-on: https://skia-review.googlesource.com/26800 > Commit-Queue: Mike Klein <mtklein@chromium.org> > Reviewed-by: Brian Osman <brianosman@google.com> TBR=mtklein@chromium.org,brianosman@google.com Change-Id: I695dddaab3b5a51e4698bb7222fc723b544a1d64 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/26943 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/ok.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/tools/ok.cpp b/tools/ok.cpp
index 8d24b4ddcb..edda9bede0 100644
--- a/tools/ok.cpp
+++ b/tools/ok.cpp
@@ -69,14 +69,13 @@ static thread_local const char* tls_currently_running = "";
static void defer_logging() {
log_fd = fileno(tmpfile());
- }
-
- static void print_deferred_logs() {
- lseek(log_fd, 0, SEEK_SET);
- char buf[1024];
- while (size_t bytes = read(log_fd, buf, sizeof(buf))) {
- write(2/*stderr*/, buf, bytes);
- }
+ atexit([] {
+ lseek(log_fd, 0, SEEK_SET);
+ char buf[1024];
+ while (size_t bytes = read(log_fd, buf, sizeof(buf))) {
+ write(2, buf, bytes);
+ }
+ });
}
void ok_log(const char* msg) {
@@ -92,7 +91,6 @@ static thread_local const char* tls_currently_running = "";
#else
static void setup_crash_handler() {}
static void defer_logging() {}
- static void print_deferred_logs() {}
void ok_log(const char* msg) {
fprintf(stderr, "%s\n", msg);
@@ -155,7 +153,7 @@ struct ThreadEngine : Engine {
struct ForkEngine : Engine {
bool spawn(std::function<Status(void)> fn) override {
switch (fork()) {
- case 0: exit((int)fn());
+ case 0: _exit((int)fn());
case -1: return false;
default: return true;
}
@@ -334,7 +332,6 @@ int main(int argc, char** argv) {
update_stats(s);
}
printf("\n");
- print_deferred_logs();
return (failed || crashed) ? 1 : 0;
}