Support SIGINFO (and SIGUSR1 for POSIX purposes) to tell what long-running jobs are doing, as inspired by BSD tools (including on macOS), by dumping the current PrettyStackTrace.
This adds a new kind of signal handler for non-fatal "info" signals, similar to the "interrupt" handler that already exists for SIGINT (Ctrl-C). It then uses that handler to update a "generation count" managed by the PrettyStackTrace infrastructure, which is then checked whenever a PrettyStackTraceEntry is pushed or popped on each thread. If the generation has changed—i.e. if the user has pressed Ctrl-T—the stack trace is dumped, though unfortunately it can't include the deepest entry because that one is currently being constructed/destructed.
Out of scope:
- Multiple SIGINFO callbacks. I don't know how interesting this is anyway, given that they're still bound by what a signal handler can do.
- Windows support. Windows console programs don't seem to have a SIGINFO equivalent anyway, so when someone figures out the right thing, they can add equivalent support.
- Choosing whether to include SIGUSR1. I did this just because it was mentioned when I was looking up things about SIGINFO, but SIGINFO is the one I care about, so if people tell me they're not sure about SIGUSR1 I'll just remove it.
- Figuring out how to print the actual current PrettyStackTrace, instead of the parent one, despite the construction/destruction problem. The simplest answer I can think of requires changing all of the PrettyStackTraceEntry instances in existence, which probably isn't going to fly for something that's ultimately a convenience feature. Someone else can figure it out.