register SIGTERM handler in DM
This should make it clear when we are terminated, and print out our memory usage on the way out the door. There's no way to register a handler for SIGKILL, so if we're being cut down that way, we'll have to restructure DM quite a bit internally to spawn processes instead of threads. The parent process should be able to at least notice that child processes have been SIGKILL'd. (This would be nice anyway, so one crash doesn't ruin our whole run.) Here's a demo with a slightly hacked up DM to make the demo easy: ~/skia (sig↑1|✔) $ ninja -C out dm; and out/dm ninja: Entering directory `out' [2/2] link dm my pid is 65360 We have been politely asked to die by Terminated: 15 (15). Currently using 11MB RAM, peak 11MB. fish: 'and out/dm' terminated by signal SIGTERM (Polite quit request) Bug: skia:7614 Change-Id: Ie43be78fa766433a9d7cf391d78801d4355e635c Reviewed-on: https://skia-review.googlesource.com/107720 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
parent
2a8c48be4f
commit
c7278ad1d9
12
dm/DM.cpp
12
dm/DM.cpp
@ -263,7 +263,7 @@ static void find_culprit() {
|
||||
return x > max_of(rest...) ? x : max_of(rest...);
|
||||
}
|
||||
|
||||
static void (*previous_handler[max_of(SIGABRT,SIGBUS,SIGFPE,SIGILL,SIGSEGV)+1])(int);
|
||||
static void (*previous_handler[max_of(SIGABRT,SIGBUS,SIGFPE,SIGILL,SIGSEGV,SIGTERM)+1])(int);
|
||||
|
||||
static void crash_handler(int sig) {
|
||||
SkAutoMutexAcquire lock(gMutex);
|
||||
@ -289,11 +289,21 @@ 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 };
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user