From 701a35812e86f6c64d916d87d69e42c304fb7be2 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Thu, 28 Jun 2018 14:08:19 +0000 Subject: unify term/crash handlers, include SIGINT We print different things for crashes and for external termination signals, which is a waste. Might as well print the union for all. This adds SIGINT (Ctrl-C, signal 2, exit code 130) to the list too. (The flag to ignore sigint should still work.) Change-Id: I91db023eb68e4798eed15d1f4d76b20b52a174cc Reviewed-on: https://skia-review.googlesource.com/138160 Auto-Submit: Mike Klein Reviewed-by: Joe Gregorio Commit-Queue: Joe Gregorio --- dm/DM.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'dm') diff --git a/dm/DM.cpp b/dm/DM.cpp index b0d86420e6..28369e9c08 100644 --- a/dm/DM.cpp +++ b/dm/DM.cpp @@ -268,7 +268,10 @@ static void find_culprit() { static void crash_handler(int sig) { SkAutoMutexAcquire lock(gMutex); - info("\nCaught signal %d [%s], was running:\n", sig, strsignal(sig)); + info("\nCaught signal %d [%s] (%dMB RAM, peak %dMB), was running:\n", + sig, strsignal(sig), + sk_tools::getCurrResidentSetSizeMB(), sk_tools::getMaxResidentSetSizeMB()); + for (auto& task : gRunning) { task.dump(); } @@ -289,21 +292,11 @@ static void find_culprit() { raise(sig); } - static void term_handler(int sig) { - info("\nWe have been politely asked to die by %s (%d)." - "\nCurrently using %dMB RAM, peak %dMB.\n", - strsignal(sig), sig, - sk_tools::getCurrResidentSetSizeMB(), sk_tools::getMaxResidentSetSizeMB()); - signal(sig, previous_handler[sig]); - raise(sig); - } - static void setup_crash_handler() { - const int kSignals[] = { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV }; + const int kSignals[] = { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM }; for (int sig : kSignals) { previous_handler[sig] = signal(sig, crash_handler); } - previous_handler[SIGTERM] = signal(SIGTERM, term_handler); if (FLAGS_ignoreSigInt) { signal(SIGINT, SIG_IGN); -- cgit v1.2.3