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>
1 file changed